You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to package glslviewer for Alpine Linux, and while testing the application, I noticed that when compiled with ncurses, rapidly typing random characters in the glslviewer console would cause a crash with a segmentation fault, here is the stack trace:
#0memcpy () at src/string/x86_64/memcpy.s:18
#10x00007ffff7fb337f in sn_write (f=0x7fffffffd5e0, s=0x7fffe5d1fc70"%", l=439211896) at src/stdio/vsnprintf.c:25
#20x00007ffff7fb0872 in out (l=439211896, s=0x7fffe5d1fc70"%", f=0x7fffffffd5e0) at src/stdio/vfprintf.c:135
#3printf_core (f=f@entry=0x7fffffffd5e0, fmt=fmt@entry=0x7fffe5d1fc70"%", ap=ap@entry=0x7fffffffd448, nl_arg=nl_arg@entry=0x7fffffffd4e0,
nl_type=nl_type@entry=0x7fffffffd460) at src/stdio/vfprintf.c:639
#40x00007ffff7fb0a0b in vfprintf (f=f@entry=0x7fffffffd5e0, fmt=0x7fffe5d1fc70"%", ap=<optimized out>) at src/stdio/vfprintf.c:688
#50x00007ffff7fb3479 in vsnprintf (s=<optimized out>, n=n@entry=2147483647, fmt=<optimized out>, ap=ap@entry=0x7fffffffd6e8) at src/stdio/vsnprintf.c:54
#60x00007ffff7fb3491 in vsprintf (s=<optimized out>, fmt=<optimized out>, ap=ap@entry=0x7fffffffd6e8) at src/stdio/vsprintf.c:6
#70x00007ffff7fae416 in sprintf (s=<optimized out>, fmt=<optimized out>) at src/stdio/sprintf.c:9
#80x00007ffff7f2d506 in ?? () from /usr/lib/libncursesw.so.6
#90x00007ffff7f2f07e in _nc_tiparm () from /usr/lib/libncursesw.so.6
#100x00007ffff7f12c4b in ?? () from /usr/lib/libncursesw.so.6
#110x00007ffff7f13bba in _nc_do_color_sp () from /usr/lib/libncursesw.so.6
#120x00007ffff7f25cae in vid_puts_sp () from /usr/lib/libncursesw.so.6
#130x00007ffff7f1ff7e in ?? () from /usr/lib/libncursesw.so.6
#140x00007ffff7f20333 in ?? () from /usr/lib/libncursesw.so.6
#150x00007ffff7f2090c in ?? () from /usr/lib/libncursesw.so.6
#160x00007ffff7f2181a in ?? () from /usr/lib/libncursesw.so.6
#170x00007ffff7f21e93 in ?? () from /usr/lib/libncursesw.so.6
#180x00007ffff7f235ea in doupdate_sp () from /usr/lib/libncursesw.so.6
#190x00007ffff7f1b0fa in wrefresh () from /usr/lib/libncursesw.so.6
#200x0000555555608da3 in console_uniforms_refresh() ()
#210x00005555555db3f6 in loop() ()
#220x00005555555d77b9 in main ()
while diving a bit into the code, I noticed two things:
The ncurses windows are global variables that aren't protected by mutexes.
Both the main loop() and the cinWatcherThread(), which runs in another thread act on those variables, creating a race condition.
This race condition cause segmentation faults when passing the window to the wrefresh method of ncurses.
I also confirmed this does not happen when passing the --noncurses flag or disabling ncurses at the compilation step.
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to package
glslviewer
for Alpine Linux, and while testing the application, I noticed that when compiled withncurses
, rapidly typing random characters in the glslviewer console would cause a crash with a segmentation fault, here is the stack trace:while diving a bit into the code, I noticed two things:
ncurses
windows are global variables that aren't protected by mutexes.loop()
and thecinWatcherThread()
, which runs in another thread act on those variables, creating a race condition.This race condition cause segmentation faults when passing the window to the
wrefresh
method ofncurses
.I also confirmed this does not happen when passing the
--noncurses
flag or disabling ncurses at the compilation step.The text was updated successfully, but these errors were encountered: