[Rcpp-devel] Segmentation fault in Rcpp::DataFrame::create when data is sufficiently long

Dirk Eddelbuettel edd at debian.org
Fri Jan 13 16:29:01 CET 2012


On 13 January 2012 at 09:00, Slava Mazur wrote:
| Dirk,
| 
| As expected, switching to std::vector did not make any difference. The following leads to the same behavior:
| 
| std::vector<double> vt, vpx, vsz;
| std::vector<std::string> vsrc, vtype;
| 
| // ... initializing the above vectors here
| 
| Rcpp::DataFrame df = Rcpp::DataFrame::create(
| 	Rcpp::Named("t", vt),
| 	Rcpp::Named("type", vtype),
| 	Rcpp::Named("src", vsrc),
| 	Rcpp::Named("px", vpx),
| 	Rcpp::Named("sz", vsz)
| ); 
| 
| return Rcpp::wrap(df);
| 
| It crashes inside the "create" function when the vector size is about 100K. Note that I was able to create a similar data frame of even much bigger size in R directly (without Rcpp). 

Can you chase down where the segfault happens?
 
| What contribution are you talking about? Please clarify.

Feel free to quote. I wrote

| There is simply no wrap() support for Boost.  Care to contribute it?

and the Rcpp-extending vignette details how to extend as<>() and wrap() to
different classes.  I was of course speaking half jokingly as Boost is no
small feat---but it would be nice to have Boost support!  Someone's gotta do
it though.

Fixing the bug may be more important. If you can help there, we would
appreciate it.  

Cheers, Dirk

| 
| Thanks,
| 
| Slava Mazur
| 
| -----Original Message-----
| From: Dirk Eddelbuettel [mailto:edd at debian.org] 
| Sent: Thursday, January 12, 2012 4:19 PM
| To: Slava Mazur
| Cc: rcpp-devel at lists.r-forge.r-project.org
| Subject: Re: [Rcpp-devel] Segmentation fault in Rcpp::DataFrame::create when data is sufficiently long
| 
| 
| On 12 January 2012 at 16:00, Slava Mazur wrote:
| | Greetings,
| | 
| |  
| | 
| | My R session crashes with core dump when executing the following Rcpp call:
| | 
| |  
| | 
| | DataFrame df = Rcpp::DataFrame::create(
| | 
| |                 Rcpp::Named("t", 
| | boost::make_iterator_range(projector_num(vb,
| | get_time), projector_num(ve, get_time))),
| | 
| |                 Rcpp::Named("type", 
| | boost::make_iterator_range(projector_str
| | (vb, get_type), projector_str(ve, get_type))),
| | 
| |                 Rcpp::Named("src", 
| | boost::make_iterator_range(projector_str(vb,
| | get_src), projector_str(ve, get_src))),
| | 
| |                 Rcpp::Named("px", 
| | boost::make_iterator_range(projector_num(vb,
| | get_price), projector_num(ve, get_price))),
| | 
| |                 Rcpp::Named("sz", 
| | boost::make_iterator_range(projector_num(vb,
| | get_size), projector_num(ve, get_size))),
| | 
| |                 Rcpp::Named("stringsAsFactors", false)
| | 
| | );
| | 
| |  
| | 
| | Below is what is on the screen and a fragment of call stack. Any ideas 
| | what?s wrong here?
| 
| I'd start by disentangling this.  Start with one object.  Assign it from a Boost type a standard STL type _for which we have wrap() support_ and stick that in a data.frame.
| 
| There is simply no wrap() support for Boost.  Care to contribute it?
| 
| Dirk
|  
| |  
| | 
| | Thanks,
| | 
| |  
| | 
| | Slava Mazur
| | 
| |  
| | 
| | *** glibc detected *** 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/bin/exec/
| | R: corrupted double-linked list: 0x000000001bdd22b0 ***
| | 
| | ======= Backtrace: =========
| | 
| | /lib64/libc.so.6[0x3633073afa]
| | 
| | /lib64/libc.so.6(__libc_malloc+0x6e)[0x3633074bee]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so
| | (Rf_allocVector+0x613)[0x2ad0b19bf033]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1964
| | 315]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1918
| | 4fc]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x5
| | 77)
| | [0x2ad0b1985237]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1987
| | bd7]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x4
| | 79)
| | [0x2ad0b1985139]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1986
| | 942]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x4
| | 79)
| | [0x2ad0b1985139]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so
| | (Rf_applyClosure+0x308)[0x2ad0b1989678]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x3
| | 2b)
| | [0x2ad0b1984feb]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1985
| | 90a]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b19c7
| | 63e]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x4
| | 79)
| | [0x2ad0b1985139]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so
| | (Rf_applyClosure+0x308)[0x2ad0b1989678]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x3
| | 2b)
| | [0x2ad0b1984feb]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b198a
| | bee]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x6
| | b3)
| | [0x2ad0b1985373]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1986
| | 8ad]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x4
| | 79)
| | [0x2ad0b1985139]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b198a
| | bee]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x6
| | b3)
| | [0x2ad0b1985373]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1986
| | 942]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x4
| | 79)
| | [0x2ad0b1985139]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so
| | (Rf_applyClosure+0x308)[0x2ad0b1989678]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x3
| | 2b)
| | [0x2ad0b1984feb]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1987
| | bd7]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x4
| | 79)
| | [0x2ad0b1985139]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so[0x2ad0b1986
| | 942]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x4
| | 79)
| | [0x2ad0b1985139]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so
| | (Rf_applyClosure+0x308)[0x2ad0b1989678]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/lib/libR.so(Rf_eval+0x3
| | 2b)
| | [0x2ad0b1984feb]
| | 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/library/Rcpp/lib/libRcp
| | p.so (_ZN4Rcpp9Evaluator3runEP7SEXPRECS2_+0x54)[0x2ad0b9a49594]
| | 
| | ?
| | 
| |  
| | 
| | #0  0x0000003633030265 in raise (sig=<value optimized out>) at 
| | ../nptl/sysdeps/
| | unix/sysv/linux/raise.c:64
| | 
| | #1  0x0000003633031d10 in abort () at abort.c:88
| | 
| | #2  0x000000363306a84b in __libc_message (do_abort=<value optimized 
| | out>, fmt= <value optimized out>)
| | 
| |     at ../sysdeps/unix/sysv/linux/libc_fatal.c:170
| | 
| | #3  0x0000003633073afa in _int_malloc (av=<value optimized out>, 
| | bytes=<value optimized out>)
| | 
| |     at malloc.c:6180
| | 
| | #4  0x0000003633074bee in __libc_malloc (bytes=<value optimized out>) 
| | at
| | malloc.c:3605
| | 
| | #5  0x00002ad0b19bf033 in Rf_allocVector (type=14, length=37312) at
| | memory.c:2345
| | 
| | #6  0x00002ad0b1964315 in duplicate1 (s=0x1c5d7cd0) at duplicate.c:224
| | 
| | #7  0x00002ad0b19184fc in do_makelist (call=<value optimized out>, 
| | op=<value optimized out>,
| | 
| |     args=<value optimized out>, rho=<value optimized out>) at 
| | builtin.c:673
| | 
| | #8  0x00002ad0b1985237 in Rf_eval (e=0x1ac31068, rho=0x1bb84fe0) at 
| | eval.c:511
| | 
| | #9  0x00002ad0b1987bd7 in do_set (call=0x1ac31110, op=0x19d7bf68, 
| | args= 0x1ac310d8, rho=0x1bb84fe0)
| | 
| |     at eval.c:1722
| | 
| | #10 0x00002ad0b1985139 in Rf_eval (e=0x1ac31110, rho=0x1bb84fe0) at 
| | eval.c:482
| | 
| | #11 0x00002ad0b1986942 in do_begin (call=0x1ac2ee08, op=0x19d7bd70, 
| | args=0x6,
| | rho=0x1bb84fe0) at eval.c:1420
| | 
| | #12 0x00002ad0b1985139 in Rf_eval (e=0x1ac2ee08, rho=0x1bb84fe0) at 
| | eval.c:482
| | 
| | #13 0x00002ad0b1989678 in Rf_applyClosure (call=0x1bb95588, 
| | op=0x1ac283f8, arglist=0x1bb85960,
| | 
| |     rho=0x19da3ab0, suppliedenv=0x19da3ae8) at eval.c:838
| | 
| | #14 0x00002ad0b1984feb in Rf_eval (e=0x1bb95588, rho=0x19da3ab0) at 
| | eval.c:526
| | 
| | #15 0x00002ad0b198590a in do_eval (call=0x1b269200, op=0x19d93058, 
| | args= 0x1bb857d8, rho=0x1bb86580)
| | 
| |     at eval.c:2082
| | 
| | #16 0x00002ad0b19c763e in do_internal (call=<value optimized out>, 
| | op=<value optimized out>,
| | 
| |     args=<value optimized out>, env=0x1bb86580) at names.c:1227
| | 
| | #17 0x00002ad0b1985139 in Rf_eval (e=0x1b269190, rho=0x1bb86580) at 
| | eval.c:482
| | 
| | #18 0x00002ad0b1989678 in Rf_applyClosure (call=0x1bb89920, 
| | op=0x1b272da8, arglist=0x1bb86430,
| | 
| |     rho=0x1a6a11d8, suppliedenv=0x19da3ae8) at eval.c:838
| | 
| | #19 0x00002ad0b1984feb in Rf_eval (e=0x1bb89920, rho=0x1a6a11d8) at 
| | eval.c:526
| | 
| | #20 0x00002ad0b198abee in forcePromise (e=0x1bb89c68) at eval.c:331
| | 
| | #21 0x00002ad0b1985373 in Rf_eval (e=0x19dd05e8, rho=0x1bb88620) at 
| | eval.c:436
| | 
| | #22 0x00002ad0b19868ad in do_return (call=0x1b2a2368, op=<value 
| | optimized out>, args=0x6, rho=0x1bb88620)
| | 
| |     at eval.c:1437
| | 
| | #23 0x00002ad0b1985139 in Rf_eval (e=0x1b2a2368, rho=0x1bb88620) at 
| | eval.c:482
| | 
| | #24 0x00002ad0b198abee in forcePromise (e=0x1bb88c78) at eval.c:331
| | 
| | #25 0x00002ad0b1985373 in Rf_eval (e=0x19dd05e8, rho=0x1bb86a68) at 
| | eval.c:436
| | 
| | #26 0x00002ad0b1986942 in do_begin (call=0x1b2ac708, op=0x19d7bd70, 
| | args=0x6,
| | rho=0x1bb86a68) at eval.c:1420
| | 
| | #27 0x00002ad0b1985139 in Rf_eval (e=0x1b2ac708, rho=0x1bb86a68) at 
| | eval.c:482
| | 
| | #28 0x00002ad0b1989678 in Rf_applyClosure (call=0x1b2a22f8, 
| | op=0x1bb886c8, arglist=0x1bb87f08,
| | 
| |     rho=0x1bb88620, suppliedenv=0x19da3ae8) at eval.c:838
| | 
| | #29 0x00002ad0b1984feb in Rf_eval (e=0x1b2a22f8, rho=0x1bb88620) at 
| | eval.c:526
| | 
| | #30 0x00002ad0b1987bd7 in do_set (call=0x1b2a2218, op=0x19d7bf68, 
| | args= 0x1b2a2288, rho=0x1bb88620)
| | 
| |     at eval.c:1722
| | 
| | #31 0x00002ad0b1985139 in Rf_eval (e=0x1b2a2218, rho=0x1bb88620) at 
| | eval.c:482
| | 
| | #32 0x00002ad0b1986942 in do_begin (call=0x1b2b1d30, op=0x19d7bd70, 
| | args=0x6,
| | rho=0x1bb88620) at eval.c:1420
| | 
| | #33 0x00002ad0b1985139 in Rf_eval (e=0x1b2b1d30, rho=0x1bb88620) at 
| | eval.c:482
| | 
| | #34 0x00002ad0b1989678 in Rf_applyClosure (call=0x1bb89b88, 
| | op=0x1b2b2e38, arglist=0x1bb88578,
| | 
| | ---Type <return> to continue, or q <return> to quit---
| | 
| |     rho=0x1a6a11d8, suppliedenv=0x19da3ae8) at eval.c:838
| | 
| | #35 0x00002ad0b1984feb in Rf_eval (e=0x1bb89b88, rho=0x1a6a11d8) at 
| | eval.c:526
| | 
| | #36 0x00002ad0b9a49594 in Rcpp::Evaluator::run (expr=0x1bb95588, 
| | env=<value optimized out>)
| | 
| |     at Evaluator.cpp:36
| | 
| | #37 0x00002ad0b941de55 in create<Rcpp::traits::named_object 
| | <boost::iterator_range<boost::transform_iterator<boost::function1<doub
| | le, const <unnamed>::MyTick&>, 
| | __gnu_cxx::__normal_iterator<const<unnamed>::MyTick*,
| | std::vector<<unnamed>::MyTick, std::allocator<<unnamed>::MyTick> > >, 
| | boost::use_default, boost::use_default> > >, 
| | Rcpp::traits::named_object
| | <boost::iterator_range<boost::transform_iterator<boost::function1
| | <std::basic_string<char, std::char_traits<char>, std::allocator<char> 
| | >, const <unnamed>::MyTick&>, 
| | __gnu_cxx::__normal_iterator<const<unnamed>::MyTick*,
| | std::vector<<unnamed>::MyTick, std::allocator<<unnamed>::MyTick> > >, 
| | boost::use_default, boost::use_default> > >, 
| | Rcpp::traits::named_object
| | <boost::iterator_range<boost::transform_iterator<boost::function1
| | <std::basic_string<char, std::char_traits<char>, std::allocator<char> 
| | >, const <unnamed>::MyTick&>, 
| | __gnu_cxx::__normal_iterator<const<unnamed>::MyTick*,
| | std::vector<<unnamed>::MyTick, std::allocator<<unnamed>::MyTick> > >, 
| | boost::use_default, boost::use_default> > >, 
| | Rcpp::traits::named_object 
| | <boost::iterator_range<boost::transform_iterator<boost::function1<doub
| | le, const <unnamed>::MyTick&>, 
| | __gnu_cxx::__normal_iterator<const<unnamed>::MyTick*,
| | std::vector<<unnamed>::MyTick, std::allocator<<unnamed>::MyTick> > >, 
| | boost::use_default, boost::use_default> > >, 
| | Rcpp::traits::named_object 
| | <boost::iterator_range<boost::transform_iterator<boost::function1<doub
| | le, const <unnamed>::MyTick&>, 
| | __gnu_cxx::__normal_iterator<const<unnamed>::MyTick*,
| | std::vector<<unnamed>::MyTick, std::allocator<<unnamed>::MyTick> > >, 
| | boost::use_default, boost::use_default> > >, 
| | Rcpp::traits::named_object<bool> > (t1=@0x7fff460545c0, 
| | t2=@0x7fff460544b0, t3=@0x7fff460543a0, t4= @0x7fff46054290,
| | 
| |     t5=@0x7fff46054180, t6=@0x7fff46054150)
| | 
| |     at 
| | /appdata/packages/shareware/R/R-2.13.1/lib64/R/library/Rcpp/include/Rc
| | pp
| | /DataFrame_generated.h:87
| | 
| |  
| | 
| | 
| | ----------------------------------------------------------------------
| | _______________________________________________
| | Rcpp-devel mailing list
| | Rcpp-devel at lists.r-forge.r-project.org
| | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-deve
| | l
| --
| "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx
| 
| 

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list