Message-ID: <50B900E9.8080608@gmail.com>
Date: 2012-11-30T18:54:33Z
From: Duncan Murdoch
Subject: segfault debugging
In-Reply-To: <1354294954.76050.YahooMailNeo@web171506.mail.ir2.yahoo.com>
On 30/11/2012 12:02 PM, Donatella Quagli wrote:
> Hello everybody,
>
> I have written a script with two inline cfunctions. The script crashes from time to time with:
> *** caught segfault ***
> address 0x10, cause 'memory not mapped'
>
> The crashs happen within R code after the cfunctions were executed. Nevertheless I think
> that the pointers in my cfunctions are not used correctly.
>
> I tried to find some examples for debugging tools. I found something like "R -d gdb". But I
> could not find an example how to use it with #!/usr/bin/Rscript. And I cannot source the script
> within a running R session because I must run it with some args.
>
> Can anybody tell me as a non nerd step by step what I can do to locate the problem? Can
> you recommend tools? If so how are they used with Rscript?
This isn't easy, but what I would do is add something to your script to
get it to pause (or to wait for some file to be created, or some other
signal), then figure out the process number, and tell gdb to connect to
it after it has already started.
The ps command will list all the running processes, for some definition
of "all". Then
gdb --pid=PID
will connect to the process with id PID. I believe it will interrupt
the process at that point, but you can restart it, send the signal to it
to get out of its loop), and hopefully see the segfault in action.
Duncan Murdoch