From murdoch at stats.uwo.ca  Wed Jan 24 21:13:24 2007
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed, 24 Jan 2007 15:13:24 -0500
Subject: [Rd] how to trace what crashes R
In-Reply-To: <20070124194701.GA11252@eddelbuettel.com>
References: <8570488.post@talk.nabble.com>
	<20070124194701.GA11252@eddelbuettel.com>
Message-ID: <45B7BDE4.9090704@stats.uwo.ca>

On 1/24/2007 2:47 PM, Dirk Eddelbuettel wrote:
> On Wed, Jan 24, 2007 at 11:15:49AM -0800, Vladimir Eremeev wrote:
>> The problem is. R crashes with the "segmentation violation".
>> Tracing with the insight and with simple Rprintf's gave me that crash occurs
>> on the call of the function deeply in the snns kernel. 
>> That is, R correctly calls C wrapper, it calls the kernel function from the
>> so called "user interface" part, it calls another C function from the
>> internals, and that one calls the third C function. 
>> And the segmentation fault occurs on the call of that function, it doesn't
>> do anything, its arguments have correct values, and it works in the other
>> situations, for example, when I run executables from the SNNS (either gui
>> version of the simulator, or batch interpreter).
>> Moreover, I don't think the reason in the incorrect arguments, since the
>> called function doesn't do anything. 
>> Rprintf in the very beginning of its body doesn't work (I traced it in
>> console mode of R).
>> 
>> How could I trace, what happens?
> 
> Compile snns with debugging support, compile R with debugging, start R
> as 
> 
>    $ R -d gdb		## or ddd if you have it
>    
> and use the debugger.  There is a lot of useful information in the
> fine manual on 'R Extensions'.

Since Vladimir is using MinGW he's on Windows, and things are slightly 
different:  you would use

insight rgui

to start the debugger.  Other than that, it's mostly the same; details 
aimed at Windows are given in my web page

http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/

in the "Using gdb to debug C or Fortran code" section.

Duncan Murdoch



[Rd] how to trace what crashes R
Duncan Murdoch