GNU bug report logs -
#76393
Warn about -fsanitizer=address builds
Previous Next
Reported by: Pip Cet <pipcet <at> protonmail.com>
Date: Tue, 18 Feb 2025 12:35:02 UTC
Severity: wishlist
Done: Pip Cet <pipcet <at> protonmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 2/18/25 07:48, Pip Cet wrote:
> Building Emacs with address sanitization can help debug memory-use
> -problems, such as freeing the same object twice. To use
> -AddressSanitizer with GCC and similar compilers, append
> +problems, such as freeing the same object twice. However,
> +-fsanitize=address also introduces bugs in the compiled code which cause
> +GC problems and phantom crashes, which do not always look like they're
> +caused by the address sanitizer.
I don't see a GCC bug there. What I see is an incompatibility with
Emacs's garbage collector, a collector which relies on several aspects
of undefined behavior in C. So I suggest changing the last three lines
to something like this:
as the default behavior of -fsanitize=address is incompatible with
ordinary Emacs operation, it needs to be combined with other options.
> +ASAN_OPTIONS='detect_stack_use_after_return=0,detect_leaks=0' in the
> +environment to suppress diagnostics of minor memory leaks in Emacs, and
> +buggy code which relocates objects from the stack to the heap . For
> +example:
Here, change "buggy code which relocates" to "to suppress relocation
of". Also, omit the space before ".".
Otherwise, it looks good.
I've found -fsanitize=address to be verrrrry helpful when debugging
obscure memory problems, and it's good to document how to use it.
It would be even better if we changed Emacs so that ASAN_OPTIONS need
not contain set detect_stack_use_after_return=0, as that would help
detect more errors. -fsanitize=address has support for this sort of
thing; see its __asan_addr_is_in_fake_stack function. However, Emacs
currently doesn't use that support, so we must currently settle for
detect_stack_use_after_return=0.
This bug report was last modified 76 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.