I am writing a program using POSIX threads and OpenGL (MesaGL). I have one
thread doing the GL and another one letting the user input from the
console. I am getting an odd segfault, and the core dump shows the stack
trace from the thread letting the user input commands:
(gdb) backtrace
#0 0x4029ead4 in __libc_read ()
#1 0x401d8d3c in __DTOR_END__ ()
#2 0x4024e4a9 in _IO_file_read (fp=0x8057120, buf=0x401c0000, size=4096)
at fileops.c:679
#3 0x8050f2e in filebuf::sys_read (this=0x8057120,
buf=0x401c0000 "10000\nrt(m_tail);\n", size=4096) at filebuf.cc:180
#4 0x4024d951 in _IO_new_file_underflow (fp=0x8057120) at fileops.c:385
#5 0x8050eaa in filebuf::underflow (this=0x8057120) at filebuf.cc:160
#6 0x4024f8a1 in _IO_default_uflow (fp=0x8057120) at genops.c:371
#7 0x804fd4e in streambuf::uflow (this=0x8057120) at streambuf.cc:63
#8 0x4024ed0c in __uflow (fp=0x8057120) at genops.c:328
#9 0x402467d2 in _IO_vfscanf (s=0x8057120, format=0x80558e8 " %i",
argptr=0xbffffb74, errp=0x0) at vfscanf.c:501
#10 0x402498ca in scanf (format=0x80558e8 " %i") at scanf.c:33
#11 0x804bc89 in ConsoleRoutine () at project.C:193
#12 0x804b9c4 in main () at project.C:135
#13 0x402109cb in __libc_start_main (main=0x804b934 <main>, argc=1,
argv=0xbffffc04, init=0x804a8dc <_init>, fini=0x80557c0 <_fini>,
rtld_fini=0x4000ae60 <_dl_fini>, stack_end=0xbffffbfc)
at ../sysdeps/generic/libc-start.c:92
(gdb) info threads
* 1 Thread 11642 0x4029ead4 in __libc_read ()
Unfortunately, the core dump only shows one thread. When I try to run the
program from gdb, gdb says:
[New Thread 11777]
[New Thread 11775]
when I start the new thread for OpenGL. The only way I can seem to get
back to the gdb prompt is sending SIGCONT to both threads. The backtrace
shows that the one thread is stuck in pthread_create. Unfortunately, I do
not know why, but this no longer seems to work... But when it did, typing
in 'cont' put me in the same situation, then SIGSTOP would give me the gdb
prompt again, but the stacktraces didn't change at all... So.. how do I do
start the threads and still give gdb control?? (Breakpoints did not help
b/c the threads seem to be stuck.)
My program does work, except for when I put it under very high loads. Then
it segfaults. I looked in the online gdb manual (the big one RMS wrote)
and it said very little about threads and gdb.
Help!
--
Electrical Engineers do it with less resistance.
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]