failed to restore the stack

1,227 views
Skip to first unread message

Rik Prohaska

unread,
Sep 3, 2015, 10:13:55 AM9/3/15
to thread-sanitizer
Hello,

I am trying to solve some data races reported by TSAN.  Unfortunately, the conflicting operation is not being reported.  I see 'failed to restore the stack' instead, which makes the race hard to track down.  Is there an option that may effect this?

Thanks

Dmitry Vyukov

unread,
Sep 3, 2015, 10:16:58 AM9/3/15
to thread-s...@googlegroups.com
See:
https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags

If you run with TSAN_OPTIONS="history_size=7", it will make tsan to
remember more stacks but increase memory consumption.
Also, you can run for longer, there are changes that you will observe
the same race with the second stack trace.

markdavi...@gmail.com

unread,
Sep 13, 2018, 2:13:43 PM9/13/18
to thread-sanitizer
Hello,

I'm having the same issue. I've tried the following:

* running with history_size=7
* running with verbosity=2
* running both on linux and osx
* running program for a long time

I'm debugging a race. The "write" always shows the stack trace, but the "read" always says "failed to restore the stack".

All of the race warnings that have this issue (described above) are for the same line of code. Stacks do print out properly for any other races in my program.

I'm running on clang 6.0.1.

Any ideas?

Dmitry Vyukov

unread,
Sep 14, 2018, 1:00:56 AM9/14/18
to thread-sanitizer
On Thu, Sep 13, 2018 at 8:13 PM, <markdavi...@gmail.com> wrote:
> Hello,
>
> I'm having the same issue. I've tried the following:
>
> * running with history_size=7
> * running with verbosity=2
> * running both on linux and osx
> * running program for a long time
>
> I'm debugging a race. The "write" always shows the stack trace, but the
> "read" always says "failed to restore the stack".
>
> All of the race warnings that have this issue (described above) are for the
> same line of code. Stacks do print out properly for any other races in my
> program.
>
> I'm running on clang 6.0.1.
>
> Any ideas?

No ideas.
The access probably was done too long time ago and is already evicted
from memory.


> On Thursday, September 3, 2015 at 10:16:58 AM UTC-4, Dmitry Vyukov wrote:
>>
>> On Thu, Sep 3, 2015 at 4:13 PM, Rik Prohaska <proh...@gmail.com> wrote:
>> > Hello,
>> >
>> > I am trying to solve some data races reported by TSAN. Unfortunately,
>> > the
>> > conflicting operation is not being reported. I see 'failed to restore
>> > the
>> > stack' instead, which makes the race hard to track down. Is there an
>> > option
>> > that may effect this?
>>
>> See:
>> https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags
>>
>> If you run with TSAN_OPTIONS="history_size=7", it will make tsan to
>> remember more stacks but increase memory consumption.
>> Also, you can run for longer, there are changes that you will observe
>> the same race with the second stack trace.
>
> --
> You received this message because you are subscribed to the Google Groups
> "thread-sanitizer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to thread-sanitiz...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

markdavi...@gmail.com

unread,
Sep 14, 2018, 9:14:05 AM9/14/18
to thread-sanitizer
Oh I see. This race would happen at the very beginning of the program (at initialization of different structures). So, I will try to run the program to exit quickly. Could this help?

Just out of curiosity, does the memory that you're referring to get evicted only by other TSAN warnings or data, or something else?

Dmitry Vyukov

unread,
Sep 14, 2018, 9:17:47 AM9/14/18
to thread-sanitizer
On Fri, Sep 14, 2018 at 3:14 PM, <markdavi...@gmail.com> wrote:
> Oh I see. This race would happen at the very beginning of the program (at
> initialization of different structures). So, I will try to run the program
> to exit quickly. Could this help?

This may help.

> Just out of curiosity, does the memory that you're referring to get evicted
> only by other TSAN warnings or data, or something else?

It is evicted by memory accesses and function calls. Tsan needs to
memorize stack traces for all memory accesses that ever happened in
the program, for the case a memory access races with another in
future. But when a memory access happens we don't know yet if it will
race in future or not, so it needs to remember all of them. It's
inherently challenging as it produces tons of information to memorize
and we can't keep infinite amount of information in memory.
Reply all
Reply to author
Forward
0 new messages