From antonio.dinarzo at studio.unibo.it  Mon Jun 13 10:43:07 2005
From: antonio.dinarzo at studio.unibo.it (antonio.dinarzo@studio.unibo.it)
Date: Mon, 13 Jun 2005 10:43:07 +0200
Subject: [Rd] memory allocation problem under linux
Message-ID: <1118652187.42ad471bd917f@posta.studio.unibo.it>

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.



[Rd] memory allocation problem under linux
antonio.dinarzo@studio.unibo.it