[Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

Douglas Bates bates at stat.wisc.edu
Wed Jan 5 18:55:39 CET 2011


This time with the enclosure :-)

On Wed, Jan 5, 2011 at 11:52 AM, Douglas Bates <bates at stat.wisc.edu> wrote:
> I don't know whether this is through error on my part or because of an
> "infelicity" in the Rcpp module code but the lme4a package, which now
> uses Rcpp modules extensively, ends up with some difficult-to-trace
> memory corruption issues.  Yesterday i finally bit the bullet and ran
> a test with gctorture(TRUE) and valgrind enabled.  It takes a very
> long time and results in a segfault when trying to load the package.
> I enclose the transcript.  I should say that this is using Rcpp_0.9.0
> from CRAN, not the SVN version of Rcpp.
>
> I just got these results this morning (it was running overnight) and
> haven't looked at the code in Module.cpp and cache.cpp yet.  If it
> seems likely that the code is beyond me I can try to work out a
> simpler example that triggers the problem.
>
-------------- next part --------------
==15160== Memcheck, a memory error detector
==15160== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==15160== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==15160== Command: /home/bates/build/R-devel/bin/exec/R --no-save --no-restore
==15160== 
==15160== Conditional jump or move depends on uninitialised value(s)
==15160==    at 0x6870E40: inflateReset2 (in /lib/libz.so.1.2.3.4)
==15160==    by 0x6870F2F: inflateInit2_ (in /lib/libz.so.1.2.3.4)
==15160==    by 0x686B1BC: ??? (in /lib/libz.so.1.2.3.4)
==15160==    by 0x4EB019E: gzfile_open (connections.c:1186)
==15160==    by 0x4EADD57: do_gzfile (connections.c:1745)
==15160==    by 0x4F6152A: do_internal (names.c:1197)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F15C2C: Rf_applyClosure (eval.c:811)
==15160==    by 0x4F130E7: Rf_eval (eval.c:513)
==15160==    by 0x4F1A55F: do_set (eval.c:1698)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F14C6B: do_begin (eval.c:1418)
==15160== 
==15160== Conditional jump or move depends on uninitialised value(s)
==15160==    at 0x6870E40: inflateReset2 (in /lib/libz.so.1.2.3.4)
==15160==    by 0x6870F2F: inflateInit2_ (in /lib/libz.so.1.2.3.4)
==15160==    by 0x686B648: uncompress (in /lib/libz.so.1.2.3.4)
==15160==    by 0x4EA4A09: R_decompress1 (connections.c:5143)
==15160==    by 0x4FDD813: do_lazyLoadDBfetch (serialize.c:2378)
==15160==    by 0x4F1333F: Rf_eval (eval.c:498)
==15160==    by 0x4F13666: forcePromise (eval.c:331)
==15160==    by 0x4F12EDB: Rf_eval (eval.c:450)
==15160==    by 0x4EFAB0A: Rf_findFun (envir.c:1293)
==15160==    by 0x4F13063: Rf_eval (eval.c:456)
==15160==    by 0x4F4D165: R_ReplFile (main.c:100)
==15160==    by 0x4F4D279: R_LoadProfile (main.c:662)
==15160== 

R version 2.13.0 Under development (unstable) (2011-01-04 r53913)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> gctorture(TRUE)
> library(lme4a)
Loading required package: Matrix
Loading required package: lattice

Attaching package: 'Matrix'

The following object(s) are masked from 'package:base':

    det

Loading required package: minqa
Loading required package: Rcpp
==15160== Conditional jump or move depends on uninitialised value(s)
==15160==    at 0x4F0650F: Rf_promiseArgs (eval.c:1918)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160==    by 0x4E668DC: AddDLL (Rdynload.c:567)
==15160==    by 0x4E66B6E: do_dynload (Rdynload.c:900)
==15160==    by 0x4F6152A: do_internal (names.c:1197)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F15C2C: Rf_applyClosure (eval.c:811)
==15160==    by 0x4F130E7: Rf_eval (eval.c:513)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F1A55F: do_set (eval.c:1698)
==15160== 
==15160== Conditional jump or move depends on uninitialised value(s)
==15160==    at 0x4F0651E: Rf_promiseArgs (eval.c:1931)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160==    by 0x4E668DC: AddDLL (Rdynload.c:567)
==15160==    by 0x4E66B6E: do_dynload (Rdynload.c:900)
==15160==    by 0x4F6152A: do_internal (names.c:1197)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F15C2C: Rf_applyClosure (eval.c:811)
==15160==    by 0x4F130E7: Rf_eval (eval.c:513)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F1A55F: do_set (eval.c:1698)
==15160== 
==15160== Conditional jump or move depends on uninitialised value(s)
==15160==    at 0x4F53FDB: R_gc_internal (memory.c:1327)
==15160==    by 0x4F563F5: Rf_mkPROMISE (memory.c:1882)
==15160==    by 0x4F0652B: Rf_promiseArgs (eval.c:1937)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160==    by 0x4E668DC: AddDLL (Rdynload.c:567)
==15160==    by 0x4E66B6E: do_dynload (Rdynload.c:900)
==15160==    by 0x4F6152A: do_internal (names.c:1197)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F15C2C: Rf_applyClosure (eval.c:811)
==15160==    by 0x4F130E7: Rf_eval (eval.c:513)
==15160== 
==15160== Use of uninitialised value of size 8
==15160==    at 0x4F53FDD: R_gc_internal (memory.c:1327)
==15160==    by 0x4F563F5: Rf_mkPROMISE (memory.c:1882)
==15160==    by 0x4F0652B: Rf_promiseArgs (eval.c:1937)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160==    by 0x4E668DC: AddDLL (Rdynload.c:567)
==15160==    by 0x4E66B6E: do_dynload (Rdynload.c:900)
==15160==    by 0x4F6152A: do_internal (names.c:1197)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F15C2C: Rf_applyClosure (eval.c:811)
==15160==    by 0x4F130E7: Rf_eval (eval.c:513)
==15160== 
==15160== Invalid read of size 1
==15160==    at 0x4F53FDD: R_gc_internal (memory.c:1327)
==15160==    by 0x4F563F5: Rf_mkPROMISE (memory.c:1882)
==15160==    by 0x4F0652B: Rf_promiseArgs (eval.c:1937)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160==    by 0x4E668DC: AddDLL (Rdynload.c:567)
==15160==    by 0x4E66B6E: do_dynload (Rdynload.c:900)
==15160==    by 0x4F6152A: do_internal (names.c:1197)
==15160==    by 0x4F1320A: Rf_eval (eval.c:469)
==15160==    by 0x4F15C2C: Rf_applyClosure (eval.c:811)
==15160==    by 0x4F130E7: Rf_eval (eval.c:513)
==15160==  Address 0x4 is not stack'd, malloc'd or (recently) free'd
==15160== 

 *** caught segfault ***
address 0x4, cause 'memory not mapped'
==15160== Conditional jump or move depends on uninitialised value(s)
==15160==    at 0x4F53FDB: R_gc_internal (memory.c:1327)
==15160==    by 0x4F52DFD: Rf_cons (memory.c:1800)
==15160==    by 0x4F52EC1: Rf_allocList (memory.c:2147)
==15160==    by 0x4F00B24: R_GetTraceback (errors.c:1240)
==15160==    by 0x4F4CDE2: sigactionSegv (main.c:564)
==15160==    by 0x53D8C1F: ??? (in /lib/libc-2.12.1.so)
==15160==    by 0x4F53FDC: R_gc_internal (memory.c:1327)
==15160==    by 0x4F563F5: Rf_mkPROMISE (memory.c:1882)
==15160==    by 0x4F0652B: Rf_promiseArgs (eval.c:1937)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160== 
==15160== Use of uninitialised value of size 8
==15160==    at 0x4F53FDD: R_gc_internal (memory.c:1327)
==15160==    by 0x4F52DFD: Rf_cons (memory.c:1800)
==15160==    by 0x4F52EC1: Rf_allocList (memory.c:2147)
==15160==    by 0x4F00B24: R_GetTraceback (errors.c:1240)
==15160==    by 0x4F4CDE2: sigactionSegv (main.c:564)
==15160==    by 0x53D8C1F: ??? (in /lib/libc-2.12.1.so)
==15160==    by 0x4F53FDC: R_gc_internal (memory.c:1327)
==15160==    by 0x4F563F5: Rf_mkPROMISE (memory.c:1882)
==15160==    by 0x4F0652B: Rf_promiseArgs (eval.c:1937)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160== 
==15160== Invalid read of size 1
==15160==    at 0x4F53FDD: R_gc_internal (memory.c:1327)
==15160==    by 0x4F52DFD: Rf_cons (memory.c:1800)
==15160==    by 0x4F52EC1: Rf_allocList (memory.c:2147)
==15160==    by 0x4F00B24: R_GetTraceback (errors.c:1240)
==15160==    by 0x4F4CDE2: sigactionSegv (main.c:564)
==15160==    by 0x53D8C1F: ??? (in /lib/libc-2.12.1.so)
==15160==    by 0x4F53FDC: R_gc_internal (memory.c:1327)
==15160==    by 0x4F563F5: Rf_mkPROMISE (memory.c:1882)
==15160==    by 0x4F0652B: Rf_promiseArgs (eval.c:1937)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160==  Address 0x4 is not stack'd, malloc'd or (recently) free'd
==15160== 
==15160== 
==15160== Process terminating with default action of signal 11 (SIGSEGV)
==15160==  Access not within mapped region at address 0x4
==15160==    at 0x4F53FDD: R_gc_internal (memory.c:1327)
==15160==    by 0x4F52DFD: Rf_cons (memory.c:1800)
==15160==    by 0x4F52EC1: Rf_allocList (memory.c:2147)
==15160==    by 0x4F00B24: R_GetTraceback (errors.c:1240)
==15160==    by 0x4F4CDE2: sigactionSegv (main.c:564)
==15160==    by 0x53D8C1F: ??? (in /lib/libc-2.12.1.so)
==15160==    by 0x4F53FDC: R_gc_internal (memory.c:1327)
==15160==    by 0x4F563F5: Rf_mkPROMISE (memory.c:1882)
==15160==    by 0x4F0652B: Rf_promiseArgs (eval.c:1937)
==15160==    by 0x4F130BA: Rf_eval (eval.c:512)
==15160==    by 0xD5C7613: init_Rcpp_cache (cache.cpp:55)
==15160==    by 0xD5B3493: R_init_Rcpp (Module.cpp:264)
==15160==  If you believe this happened as a result of a stack
==15160==  overflow in your program's main thread (unlikely but
==15160==  possible), you can try to increase the size of the
==15160==  main thread stack using the --main-stacksize= flag.
==15160==  The main thread stack size used in this run was 8388608.
==15160== 
==15160== HEAP SUMMARY:
==15160==     in use at exit: 44,597,647 bytes in 22,683 blocks
==15160==   total heap usage: 66,029 allocs, 43,346 frees, 108,467,277 bytes allocated
==15160== 
==15160== LEAK SUMMARY:
==15160==    definitely lost: 120 bytes in 2 blocks
==15160==    indirectly lost: 480 bytes in 20 blocks
==15160==      possibly lost: 40,432,040 bytes in 21,955 blocks
==15160==    still reachable: 4,165,007 bytes in 706 blocks
==15160==         suppressed: 0 bytes in 0 blocks
==15160== Rerun with --leak-check=full to see details of leaked memory
==15160== 
==15160== For counts of detected and suppressed errors, rerun with: -v
==15160== Use --track-origins=yes to see where uninitialised values come from
==15160== ERROR SUMMARY: 2036 errors from 10 contexts (suppressed: 31 from 7)
Segmentation fault


More information about the Rcpp-devel mailing list