working c program dies in gdb

D

doug

Hi all,

Can anyone help me with the following dilema:
I have been provided with a 3rd party threaded library (say libfoo.a)
believed to be stable, it has been in use for a few years and noone has
complained about
it crashing.

The program seems to run fine.

//pseudo c-code
main()
{
statement_a;
statement_b;
call_to_function_in_lib_foo();
statement_c;
statement_d;
}

I want to run this in the debugger and experiment with some variations
in statement_c or d
BUT when I run the code in the debugger (gdb) the program generates a
segment fault in call_to_function_in_lib_foo (after spawing some
threads) but before ever executing anything on
statement_c;

If I run the program from the command line outside the debugger
and attach the debugger to the running process,
the debugger notes that there are 6 threads active, but when I try to
debug entirely in the debugger, it only gets to 4 threads and then
seg-faults.

Any ideas on why the program would work normally but fail when run in a
debugger? and any
ideas on how to resolve this?
Is this a debugger issue? library issue? (using gdb 5.3.9)

Thanks in advance...
Doug
 
R

Richard Heathfield

doug said:

Any ideas on why the program would work normally but fail when run in a
debugger?

Yes. The program is exhibiting undefined behaviour. That is, it contains a
bug.
and any ideas on how to resolve this?

Fix the bug.
Is this a debugger issue? library issue? (using gdb 5.3.9)

Programmer issue.
 
Y

Yingjian Zhan

I don't see ur exact code. here is my guess.
maybe you pass local variables to the thread creation functions. If you are
lucky enough the program can run without crashing at some chances.
but if you use a debugger things r different because the execution sequence
changed.
Just a guess. you can use bt to find out what you passed to the library
routine. Be sure they are independent to the execution sequence of threads.
BR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top