Author Topic: How to get a core dump (or debug a SIGSEGV)  (Read 6032 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
How to get a core dump (or debug a SIGSEGV)
« on: 2011 June 13 11:42:18 »
Hi,

when running my devepment module, I currently get

Code: [Select]
...
Transferring pixel data: 100%
*** PCL Unix Signal Handler: Critical signal catched (11): Segmentation violation
Reading swap files...
103.76 MB/s
<* failed *>

Usually, I would now look into the core dump to find the place where this happens. But PI is clever enough to catch this. So how should I debug this situation?

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: How to get a core dump (or debug a SIGSEGV)
« Reply #1 on: 2011 June 13 11:44:12 »
How about if you start PI from within gdb? Doesn't that give you a stack trace?
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: How to get a core dump (or debug a SIGSEGV)
« Reply #2 on: 2011 June 13 12:40:48 »
BTW, this usually appears when you go outside a matrix or image. Check the limits of your "for" loops ;)
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: How to get a core dump (or debug a SIGSEGV)
« Reply #3 on: 2011 June 18 13:24:27 »
Quote
So how should I debug this situation?

Usually you can catch the bug easily by writing control messages to stdout. For example:

std::cout << "*1" << std::flush;
... some code that perhaps throws a sigsegv
std::cout << "*2" << std::flush;

then launch PI from a terminal window. If you get this on the terminal:

*1*2

you know the problem is not within the code you are testing. However if you get only:

*1

before the exception, then you've catched it. If necessary, repeat this technique to stretch the code more and more until you get the offending bit. I use this technique and it helps me catch all bugs in the 98% of situations. Note that the calls to std::flush are essential here; without them, buffered output makes the testing code useless.

For the remaining 2%, I strongly recommend you create an Eclipse project for your module and launch the PixInsight Core application to start an interactive GDB session.

Good luck! ;)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/