Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Segmentation fault but now errors when running Valgrind

Reply
Thread Tools

Segmentation fault but now errors when running Valgrind

 
 
carl
Guest
Posts: n/a
 
      11-28-2009
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?


 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      11-28-2009
carl wrote:
> 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?

--
Ian Collins
 
Reply With Quote
 
 
 
 
carl
Guest
Posts: n/a
 
      11-28-2009

"Ian Collins" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> carl wrote:
>> 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?
>
> --
> Ian Collins


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.

 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      11-29-2009
carl wrote:
>
> "Ian Collins" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> carl wrote:
>>> 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?
>>

>
> 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.

--
Ian Collins
 
Reply With Quote
 
Ashu
Guest
Posts: n/a
 
      11-29-2009
On Nov 28, 4:23*pm, "carl" <carl@.com> wrote:
> "Ian Collins" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > carl wrote:
> >> 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?

>
> > --
> > Ian Collins

>
> 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.
 
Reply With Quote
 
Vladimir Jovic
Guest
Posts: n/a
 
      12-01-2009
Ian Collins wrote:
> carl wrote:
>>
>> "Ian Collins" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> carl wrote:
>>>> 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?
>>>

>>
>> 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.
>


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

--
ultrasound www.ezono.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting a "Segmentation Fault" when running on Linux Maxx C Programming 17 01-02-2012 05:31 PM
running memprof on ree 2010.02, gives a segmentation fault Deepak Kannan Ruby 1 08-02-2010 11:21 AM
Segmentation fault when running Rails on Windows Server 2008 Arrix Ruby 1 08-16-2008 05:23 AM
segmentation fault on long running script (linux) Vladimir Konrad Ruby 3 02-26-2007 03:42 PM
Solving Valgrind Errors dhina.jayavelu@gmail.com C Programming 1 09-25-2006 09:49 AM



Advertisments