[Rd] help with segmentation fault

Kasper Daniel Hansen khansen at stat.Berkeley.EDU
Mon May 5 00:12:58 CEST 2008


One thing that may help with debugging (and seeing if you get the same  
error on windows) is to run your code with
   R> gctorture(TRUE)
   R> your.function()

That way everything is garbage collected all the time so to speak and  
this may trigger an error on your windows machine.

I agree with Oleg - in my experience it is always a user error. You  
could also try to compile it with warnings set high(er).

Kasper

On May 4, 2008, at 2:19 PM, Oleg Sklyar wrote:

> Katie,
>
> 99% it's a bug in your C code caused by accessing memory (probably  
> writing to) which was not allocated or freed already or out of  
> boundary.  The fact that it worked fine on Windows is likely to be a  
> pure coincidence of different compiler/optimisation settings.  
> However, the main problem is that segfault is such a generic error  
> that without looking at the code one will not be able to tell you  
> anything.
>
> Debug it, get ddd with gdb and go step-wise or introduce lots of  
> pritouts to nail down the location of the problem.
>
> Oleg
>
> Kyeongmi Cheon wrote:
>> Hello all,
>> I'm trying to have C called by R. I wrote C codes that worked
>> perfectly fine with R-2.6.0 in
>> windows system ( using R tools).
>> I had to change to SuSE Linux (this system has 3.2 GHz  Intel
>> Xeon processors and 4 GB of RAM), the C codes were compiled okay but
>> when it was called to R-2.6.2, I got
>> error mesage :
>> ***caught segfault***
>> address 0x1df5000, cause 'memory not mapped'
>> segmentation fault
>> According to C references, this kind of error occurs when you get
>> something wrong with
>> dereferencing pointers or go out of edge of arrays. But the very same
>> codes were fine in windows
>> and I did not find any related errors in my codes. How could this
>> happen and how can I fix it? Does this have to do with different
>> systems (linux vs windows) or C/R program?
>> Thank you in advance.
>
> -- 
> Dr Oleg Sklyar * EBI-EMBL, Cambridge CB10 1SD, UK * +44-1223-494466
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list