taviso / 123elf

A native port of Lotus 1-2-3 to Linux.
1.18k stars 59 forks source link

Do not initialize termios struct with {0} #95

Closed voyageur closed 2 years ago

voyageur commented 2 years ago

It is filled later on with tcgetattr() call and current initialization causes a segmentation fault with some compilers at -O2 (tested with gcc 12.1.1 20220625 and clang 14.0.6, -O0 or gcc 11 work fine)

Backtrace with -O2 -ggdb3:

Program received signal SIGSEGV, Segmentation fault. 0x0812eebf in __unix_ioctl (fd=1, request=30211, argp=0x813f33a) at wrappers.c:48 48 struct termios tio = {0}; (gdb) bt

0 0x0812eebf in __unix_ioctl (fd=1, request=30211, argp=0x813f33a) at wrappers.c:48

1 0x08099719 in V3_vt_switch_open ()

2 0x0811219a in __unix_main ()

3 0x0812ed30 in main (argc=1, argv=0xffffd034, envp=0xffffd03c) at main.c:226

taviso commented 2 years ago

Weird! Thank you, seems good to me!

voyageur commented 2 years ago

Thanks for quick merge! Yes, this surprised me also, though I was glad to see from gdb output the fix was easy