Problem with GC and address/leak sanitizer
Johan
j at j.nl
Sun Feb 16 22:06:37 UTC 2025
On Sunday, 16 February 2025 at 21:48:31 UTC, Luís Marques wrote:
> On Sunday, 16 February 2025 at 20:18:18 UTC, Johan wrote:
>> Can you run with `ASAN_OPTIONS=verbosity=1` and make sure that
>> FakeStack is not enabled?
>> (`detect_stack_use_after_return=false`)
>
> The fake stack allocator is enabled. If I disable it via
> `ASAN_OPTIONS=detect_stack_use_after_return=1` the problem no
> longer reproduces.
>
> According to [1], integrating Fake Stack with GC requires
> special consideration. What's the status of ASan / fake stack
> support in LDC? (was it supposed to work, to be disabled by
> default, etc. ...?)
FakeStack allocates (!) space for stack variables, and points to
that "fake stack" memory with a pointer in actual CPU stack
memory. This means that the stack variables are now no longer in
memory that is scanned by the GC. The fix for that, of course, is
to include all FakeStacks in the GC scanning [1a][1b].
This used to work, but somehow does not work anymore since LDC
2.100 (I perhaps have forgotten about this and just noticed it).
[2]
You are very welcome to help investigate why it is no longer
working!
[3] is an interesting test case of how code should work.
-Johan
[1a]
https://github.com/ldc-developers/druntime/compare/d6b328be91db63aff979f584b0d1def0f746d730...1d938e0b7f668b099f9fa694b135c82ef13dec59
[1b] https://github.com/ldc-developers/ldc/pull/3888
[2]
https://github.com/ldc-developers/ldc/blob/d3f065816ec7d420f370e4c95c6000eb78187e25/tests/sanitizers/asan_fakestack_GC.d#L3
[3]
https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/asan/TestCases/Posix/gc-test.cpp
More information about the Digitalmars-d
mailing list