Monday, March 26, 2018

segfault when exiting a program

Hi,

a while ago I posted on this list because of a problem I experienced with building OpenBSD 6.2-current from source (the base system, not the kernel). Today I found the culprit, and it's rather strange: returning from main(), or calling exit() explicitly causes a segmentation fault.

A minimal example is:

int main(int argc, char **argv) { return 0; }

Evaluating cc -o test test.c; ./test should result in a segmentation fault. Here's the backtrace gdb gives me:

#0 _libc___cxa_finalize () at /usr/src/lib/libc/stdlib/atexit.c:133
#1 0x0de4d9fb in _libc_exit (status=0) at /usr/src/lib/libc/stdlib/exit.c:54
#2 0x18bef421 in main () from /home/nico/test

Anyone able to reproduce this?

Best,
Nicolas Schmidt

No comments:

Post a Comment