segmetation fault and abort trap
These are C programming questions, and the messages are specific to your OS. Please use a more appropriate list: the posting guide does say `questions involving C' should go elsewhere. For the specific question here, I think you need to ask on a MacOS list. BTW, Eric's definition is a good part of the story but not always all the story. Some systems differentiate bus errors from segfaults, and some do not. Generally segfaults come from SIGSEGV signals, bus errors from SIGBUS signals and abort traps from SIGABRT signals (and usually from the run-time support code calling the C function abort()). But I get the feeling that is not the level of explanation you are seeking.
On Wed, 28 Dec 2005, Elizabeth Lawson wrote:
Sorry, one more thing. Sometimes if crashes with Abort trap and sometimes it crashes with Segmentation fault. Help!
Thanks!
Elizabeth Lawson <lizzylaws at yahoo.com> wrote:
I fixed the problem that I was having with the segmentation error and can load it with dyn.load.
I have one more problem now that I don't understand. I am using the .C in a for loop
for( i in 1:ncol(L.D)){
new[,i]<-.C("mycode",as.double(L.D[,i]))
}
It crashes at different places each time I try to run it. So I tried
i<-1
then running
new[,i]<-.C("mycode",as.double(L.D[,i]))
repeatedly.
It works for 3-6 times then will crash with the error
abort trap
What does this mean?
Why does it work sometimes and not others?
Any suggestions?
Thanks,
Elizabeth Lawson
"Kort, Eric" wrote:
Elizabeth Lawson Wrote:
Hey, I don;t know if anyone has come across this error before...
More times than I care to remember.
I am running R on the terminal of my MAC OS X 10.3.4 and I have
written
C code and compiled it using R CMD SHLIB mycode.c There were no problems in compiling so I now have mycode.o and
mycode.so. A segmentation fault occurs when you try to access memory you didn't allocate for your use (see below). In other words, you are trying to use memory outside the segment allocated to your program (which, if allowed, could result in corrupting memory being used by other programs--which brings back unhappy memories of days gone by when an error in one program could crash the whole system). So these kinds of problems will not show up at compile time...only when you actually run the program.
I used dyn.load("mycode.so") and again, no problems. But when I try
to
use the code .C("mycode",x) I get the error Segmentation fault and R
shuts
down. Any ideas as to where my problem could be?
When I run into a segmentation fault, it is usually because I am trying
to access an element of an array that is beyond what I have allocated,
as in...
int main()
{
int *a;
a = (int*) malloc(3*sizeof(int));
printf("Fasten your seatbelts...\n");
a[4000] = 12;
return(0);
}
One less obvious way this can happen is forgetting to initialize your
arrays to the proper length before passing a reference to them to your C
function.
If you still are having trouble, you could post a small snippet of code
that recreates the error for us to examine.
HTH,
Eric
This email message, including any attachments, is for the so...{{dropped}}
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html --------------------------------- [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595