Skip to content

[Rcpp-devel] [Segfault Reason] Beginner Question: Same code *sometimes* fails due to segfault sometimes

4 messages · Sunny Srivastava, Romain Francois, Davor Cubranic +1 more

#
Hi Rcpp-users:

I am a very happy user of Rcpp. I am a statistician who can code a bit.
Recently, I have been working on making my cross validation code run faster
using Rcpp.

I have a question and wanted to check if others have faced similar problems.

My code sometimes fails with a segmentation fault error, however this
behavior cannot be replicated. That is, most of the times it runs fine and
gives appropriate results, but once in a while it will fail due to
segmentation fault and gives error like --

 *** caught segfault ***
address 0x18, cause 'memory not mapped'

I don't think this is normal, but how can it give correct answers when it
runs correctly. Any ideas?

I would be happy to share code, but I wanted to see if I am missing
something here. (I have limited experience as a C++ programmer.)

Thanks in advance for your help.

Best Regards,
S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110520/cbc2835d/attachment.htm>
#
Hello, 

Thanks for your interest in Rcpp and your kind words. 

Please send some reproducible example. Without this, there is not much we can do to help. 

Romain

Le 20 mai 2011 ? 09:59, Sunny Srivastava <research.baba at gmail.com> a ?crit :
#
On 2011-05-20, at 12:59 AM, Sunny Srivastava wrote:

            
It's sheer chance that your code is not segfaulting every time it's running. This error means your program is trying to access memory that does not belong to it. Something that was allocated was freed, or it was never allocated in the first place, but is still being accessed.

As Romain suggested, post the code that causes this. If it's really long, try to narrow it down to a small reproducible example. 

Davor
2 days later
#
Also, I had that type of error when I didn't have all of the proper
libraries linked. That can be an issue that produces this type of error.
On 5/20/11 7:39 PM, "Davor Cubranic" <cubranic at stat.ubc.ca> wrote: