Segmentation fault but now errors when running Valgrind

C

carl

I have made an application that throws a segmentation fault when I run it.

../MyApp
Segmentation fault

I have then tried to run it with Valgrind:


valgrind --leak-check=yes --track-origins=yes ./MyApp
==8389==
==8389== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 1)
==8389== malloc/free: in use at exit: 0 bytes in 0 blocks.
==8389== malloc/free: 13,153,309 allocs, 13,153,309 frees,
8,529,290,300 bytes allocated.
==8389== For counts of detected errors, rerun with: -v
==8389== All heap blocks were freed -- no leaks are possible.


So Valgrind cannot find any errors but I still get a segmentation fault when
running the app without Valgrind.

I have used almost a week to go through the code and I have written
unit-test for each part. Any ideas on how to find this error when valgrind
fails to find it or is the just a program that is cursed?
 
I

Ian Collins

carl said:
I have made an application that throws a segmentation fault when I run it.

./MyApp
Segmentation fault

What happens when you run the application under a debugger?
 
C

carl

Ian Collins said:
What happens when you run the application under a debugger?

I have tried that but the error first appears when a subrutine is called
after 20.000 to 30.000 iterations. I have made something like this:

if (call_count < call_limit) {

//call the failing function
call_count++;
}

When I set call_limit is between 20.000 and 30.000 it works fine but it
varies from call to call.

One possible way would be to put a break inside the above if-statement and
then have a starting count and a end count. But the interval would still be
around a few thousands and my fingers will begin to bleed if I need to press
the skip key in the debugger that many times.
 
I

Ian Collins

carl said:
I have tried that but the error first appears when a subrutine is called
after 20.000 to 30.000 iterations. I have made something like this:

So? Let it run and let the debugger catch the seg fault.
 
A

Ashu

I have tried that but the error first appears when a subrutine is called
after 20.000 to 30.000 iterations. I have made something like this:

if (call_count < call_limit) {

  //call the failing function
  call_count++;

}

When I set call_limit is between 20.000 and 30.000 it works fine but it
varies from call to call.

One possible way would be to put a break inside the above if-statement and
then have a starting count and a end count. But the interval would still be
around a few thousands and my fingers will begin to bleed if I need to press
the skip key in the debugger that many times.

hey, you might be using some other version of compiler dependent
library.
I faced some problem using libgcc3.2 earlier with my application and
it used to crash. I changed library and it works smooth.
 
V

Vladimir Jovic

Ian said:
So? Let it run and let the debugger catch the seg fault.

To add a small details : when it happens, use the backtrace option and
see what caused it.
 

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

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top