==8061== Invalid read of size 1
    ==8061==    at 0x4EC0F63: ??? (in /usr/lib/R/lib/libR.so)

         ...
==8061==  Address 0x4231f7a3c8360000 is not stack'd, malloc'd or (recently) 
free'd

yes, this is the first complaint from valgrind.

Running on valgrind-3.11.0 on x86_64 under Linux under Xen [as shown
elsewhere, which I have not quoted.]
The latest version of valgrind is valgrind-3.13.0 (two versions newer
than 3.11.0), so you should upgrade; although I would guess that
it might not make any difference in this particular case.


When the code crashes, the gdb terminal takes control and gives the following 
message:

*Program received signal SIGTRAP, Trace/breakpoint trap.*
*0x0000000004ec0f63 in ?? () from /usr/lib/R/lib/libR.so*

Executing the command *(gdb)  shell cat /proc/1668/maps *gives the following 
information(i've taken an excerpt from the message):

*00400000-00401000 r-xp 00000000 ca:01 108910                             
/usr/lib/R/bin/exec/R*
   [[snip]]
*052f4000-052ff000 rw-p 002ba000 ca:01 108931                             
/usr/lib/R/lib/libR.so*


The hope was that "cat /proc/PID/maps" might show something with an address
that is related to 0x4231f7a3c8360000; but I don't see anything like that
in what you report.  When interpreted as a double precision number,
then the bits 0x4231f7a3c8360000 are approximately 4.76987e+18,
which looks "random" to me.  However, the least-significant bits
are 16 zero bits (0x...0000) which does look less-than-random.

In your first message of this thread:
> I have written a lengthy C function and called it in my R script
> within a repeat loop, up till 5th iteration, the loop executes properly.
> In the 6th iteration, my R studio crashes. The last line that is executed
> before the crash is third line after the function call. In this line
> I am assigning a list from the C function to an R object.

"... assigning a list from the C function to an R object" might require
special handling.  What does the documentation for Rstudio say
about such conversions involving non-atomic data (a list, as opposed
to a floating-point value)?  Your function might have to build the list
one element at a time, or call a special function inside Rstudio
in order to allocate space for the list.  A plain "malloc(...)"
in your C function might not be good enough to interoperate with Rstudio.

So at this point, it seems to me that you should find an example
where someone else has a plugin C function that creates a list of
floating-point values [possibly using malloc() in C], and returns
that list to Rstdio.  Adapt your code based on that example.
In particular, construct the list using the same method.  The
numerical values of the elements will be different, of course.

--


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to