[Rd] memory allocation problem under linux

From: <antonio.dinarzo_at_studio.unibo.it>
Date: Mon 13 Jun 2005 - 08:43:07 GMT

I have some compiled code that works under winXp but not under linux (kernel 2.6.10-5). I'm also using R 2.1.0
After debugging, I've discovered that in this code:   #define NMAX 256
  long **box;

  box = (long **)R_alloc(NMAX, sizeof(long *)); //<---HERE THE SIGSEGV   for (i=0; i<NMAX; i++) box[i] = (long *) R_alloc(NMAX, sizeof(long)); inside the *first* call to the function R_alloc I have a segmentation fault. Changing R_alloc with Calloc and malloc gives the same result. However, in the same shared library, I have another function with this code:   partitions=16;

  h2=(long **)R_alloc(partitions,sizeof(long *));   for (i=0;i<partitions;i++)

      h2[i]=(long *)R_alloc(partitions,sizeof(long)); that works! Naturally, I've tried to change NMAX from 256 to 16, without any success.
I've changed optimization flags from O2 to O and O2, without success. Any idea on where the problem *should* reside? (Note that this not happens under WinXp!).

Antonio, Fabio Di Narzo.

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Jun 13 18:47:37 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:09 GMT