Issue 63313
Summary Leak Sanitizer reports leaks on `sigaltstack` pointers.
Labels new issue
Assignees
Reporter mvanotti
    LSAN is reporting leaks for legit uses of the `sigaltstack` .

See the following example:

```c++
#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

constexpr size_t kSigaltstackSize = 0x1000 * 10;

int main(void) {
  uintptr_t new_sigaltstack =
 reinterpret_cast<uintptr_t>(malloc(kSigaltstackSize)) + kSigaltstackSize;

  stack_t ss = {.ss_sp = reinterpret_cast<void *>(new_sigaltstack),
                .ss_flags = 0,
 .ss_size = kSigaltstackSize};
  sigaltstack(&ss, NULL);

  return 0;
}
```

compiled with `clang++ -fsanitize=leak program.cc -o program`

Returns:

```
=================================================================
==407264==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 40960 byte(s) in 1 object(s) allocated from:
    #0 0x5607c7b1df32 in malloc (/home/user/program+0x2ff32) (BuildId: 1fd845c27ab0d578242521bcf8e1508798c8bbcd)
    #1 0x5607c7b20688 in main (/home/user/program+0x32688) (BuildId: 1fd845c27ab0d578242521bcf8e1508798c8bbcd)
    #2 0x7fed3d367189 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:10:10

SUMMARY: LeakSanitizer: 40960 byte(s) leaked in 1 allocation(s).
```

Would it be possible for LSAN to treat the sigaltstack as a global variable?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to