[Bug libc/32884] New: There may be some issue with `atexit()`

Cabbaken at outlook dot com sourceware-bugzilla@sourceware.org
Thu Apr 17 11:26:06 GMT 2025


https://sourceware.org/bugzilla/show_bug.cgi?id=32884

            Bug ID: 32884
           Summary: There may be some issue with `atexit()`
           Product: glibc
           Version: 2.41
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: Cabbaken at outlook dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The same `atexit()` called, but gives with two different implementation here
with the code:
```cpp
#include <iostream>
struct Foo {
  struct Foo *other;
};
int main() {
  auto f1 = new Foo();
  auto f2 = new Foo();
  f1->other = f2;
  f2->other = f1;
//   std::cout<<f1<<" "<<f2<<"\n";
  std::cout<<&f1<<" "<<&f2<<"\n";
  auto t1 = &f1;
  auto t2 = &f2;
  return 0;
}
```
compiled with
```bash
clang++ -fsanitize=address t.cpp
```
which generated:
```
0000000000115280 <atexit>:
  115280: f3 0f 1e fa                   endbr64
  115284: 48 8b 15 9d ae 03 00          movq    0x3ae9d(%rip), %rdx     #
0x150128 <__dso_handle>
  11528b: 31 f6                         xorl    %esi, %esi
  11528d: e9 7d 10 f3 ff                jmp     0x4630f
<__interceptor_trampoline___cxa_atexit>
  115292: 90                            nop
  115293: 66 2e 0f 1f 84 00 00 00 00 00 nopw    %cs:(%rax,%rax)
  11529d: 0f 1f 00                      nopl    (%rax)
```
and
```bash
clang++ -fsanitize=leak t.cpp
```
which generated:
```
00000000000391c0 <atexit>:
   391c0: f3 0f 1e fa                   endbr64
   391c4: 48 8b 15 95 7f 01 00          movq    0x17f95(%rip), %rdx     #
0x51160 <__dso_handle>
   391cb: 31 f6                         xorl    %esi, %esi
   391cd: ff 25 c5 7d 01 00             jmpq    *0x17dc5(%rip)          #
0x50f98 <syslog@GLIBC_2.2.5+0x50f98>
   391d3: 66 2e 0f 1f 84 00 00 00 00 00 nopw    %cs:(%rax,%rax)
   391dd: 0f 1f 00                      nopl    (%rax)
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list