Treat the fake stack as live memory.
Somewhat ugly but does the job.
We still need to somehow solve (in a separate CL) the issue of stale pointers in reused frames, by doing one of the following:
- clearing memory in FakeStack::Allocate(). Likely prohibitively expensive, but could improve leak detection beyond what we have currently (with UAR disabled).
- storing the true size for each fake frame, and ignoring the unused space. This would be equivalent to what we have without UAR. Can we afford one extra uptr field in FakeFrame? Looks like the size of that structure is hardcoded into the instrumentation code somehow?
Some frames might be pending garbage collection. I wonder if it would be safe to filter them out based on the stack pointer value that we have from ptrace? (I.e. the same way as in FakeStack::GC() above.)
Can we just call GC here?
maybe ForEachExtraRootChunk or similar?
you should use has_fake_stack()
We can. What I'm wondering is whether it would be safe to pass the SP value as the real_stack parameter (or whether this could go wrong if we froze the threads at an unfortunate point).
I share this sentiment. Unfortunately, the way we use this function already assumes that it deals with stack (i.e. we call it under "if (flags()->use_stack)", and log the range as a stack range). Perhaps ForEachExtraStackRange?