detect_stack_use_after_return

9 views
Skip to first unread message

Ted Lyngmo

unread,
Jun 20, 2024, 2:05:11 PM (9 days ago) Jun 20
to address-sanitizer
Hi!

We have some unit tests failing because of `ber_decode` from the https://github.com/vlm/asn1c library fails when running with `detect_stack_use_after_return=1`. There is no sanitizer output, but the function just fails.

It seems to only happen in 64-bit mode and we've previously increased the stack size to get around a similar issue, but this time, I can't figure out how to either solve the underlying problem - or how to give the sanitizer the stack it needs. I simply want to turn `detect_stack_use_after_return` off even if provided via `ASAN_OPTIONS`.

My current workaround it rather ugly:
```
extern "C" void __attribute__((constructor)) disable_asan()
{
    if (auto opts = std::getenv("ASAN_OPTIONS"); opts)
    {
        if (std::ifstream is("/proc/self/cmdline"); is)
        {
            if (std::string cmd(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>{}); not cmd.empty())
            {
                std::clog << "RESTARTING \"" << cmd << "\" WITHOUT ASAN_OPTIONS=" << opts << '\n';
                unsetenv("ASAN_OPTIONS");
                exit(system(cmd.c_str()));
            }
        }
    }
}
```
What would be a cleaner way to either prevent this option from being used - or get to the root cause (since I don't get any Asan output)?

Br,
Ted
Reply all
Reply to author
Forward
0 new messages