Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in Rcpp::DataFrame::create when data is sufficiently long #226

Closed
tmanka opened this issue Jan 14, 2015 · 6 comments
Closed

Comments

@tmanka
Copy link

tmanka commented Jan 14, 2015

We are encountering a crash that looks very similar to what was reported on the R forum. Not sure if it ever made it to a bug.

R isn't handling the dataframes created by Rcpp well and looks like crahes in its allocator.

I orginally added this bug to R but it was rejected by
Duncan Murdoch 2015-01-13 17:30:25 UTC

and Duncan said:

"Rcpp is a contributed package; this but list is for bugs in R. Please don't report contributed package bugs here."

http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-January/003345.html

Please let me know if this is the right place to report this issue.

Thanks,
Ted

Ours:
(gdb) bt
#0 0x00000039cd832925 in raise () from /lib64/libc.so.6
#1 0x00000039cd834105 in abort () from /lib64/libc.so.6
#2 0x000000000056f5af in handleSignals(int) ()
#3
#4 0x00007f3695a92239 in Rf_getCharCE () from /opt/vertica/R/lib/libR.so
#5 0x00007f3695a9235d in Rf_translateChar () from /opt/vertica/R/lib/libR.so
#6 0x00007f369598fc07 in vector2buff () from /opt/vertica/R/lib/libR.so
#7 0x00007f369598f0ba in deparse2buff () from /opt/vertica/R/lib/libR.so
#8 0x00007f369598cbe5 in deparse2 () from /opt/vertica/R/lib/libR.so
#9 0x00007f369598bab3 in deparse1WithCutoff () from /opt/vertica/R/lib/libR.so
#10 0x00007f369598bd23 in Rf_deparse1line () from /opt/vertica/R/lib/libR.so
#11 0x00007f369595b6e4 in coerceVectorList () from /opt/vertica/R/lib/libR.so
#12 0x00007f369595bd7d in Rf_coerceVector () from /opt/vertica/R/lib/libR.so
#13 0x00007f369595c20f in ascommon () from /opt/vertica/R/lib/libR.so
#14 0x00007f369595cbb4 in do_asvector () from /opt/vertica/R/lib/libR.so
#15 0x00007f36959e2c44 in bcEval () from /opt/vertica/R/lib/libR.so
#16 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#17 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#18 0x00007f3695a23dda in applyMethod () from /opt/vertica/R/lib/libR.so
#19 0x00007f3695a24988 in Rf_usemethod () from /opt/vertica/R/lib/libR.so
#20 0x00007f36959dd977 in Rf_DispatchOrEval () from /opt/vertica/R/lib/libR.so
#21 0x00007f369595c666 in do_ascharacter () from /opt/vertica/R/lib/libR.so
#22 0x00007f36959d88c9 in Rf_eval () from /opt/vertica/R/lib/libR.so
#23 0x00007f3695a2b432 in do_paste () from /opt/vertica/R/lib/libR.so
#24 0x00007f36959e2c44 in bcEval () from /opt/vertica/R/lib/libR.so
#25 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#26 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#27 0x00007f36959d8964 in Rf_eval () from /opt/vertica/R/lib/libR.so
#28 0x00007f36959d80bc in forcePromise () from /opt/vertica/R/lib/libR.so
#29 0x00007f36959d8401 in Rf_eval () from /opt/vertica/R/lib/libR.so
#30 0x00007f36959d80bc in forcePromise () from /opt/vertica/R/lib/libR.so
#31 0x00007f36959d8492 in Rf_eval () from /opt/vertica/R/lib/libR.so
#32 0x00007f36959e2093 in bcEval () from /opt/vertica/R/lib/libR.so
#33 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#34 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#35 0x00007f36959d8964 in Rf_eval () from /opt/vertica/R/lib/libR.so
#36 0x00007f36959d80bc in forcePromise () from /opt/vertica/R/lib/libR.so
#37 0x00007f36959ecaea in FORCE_PROMISE () from /opt/vertica/R/lib/libR.so
#38 0x00007f36959ecc0a in getvar () from /opt/vertica/R/lib/libR.so
#39 0x00007f36959e108d in bcEval () from /opt/vertica/R/lib/libR.so
#40 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#41 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#42 0x00007f36959d8964 in Rf_eval () from /opt/vertica/R/lib/libR.so
#43 0x00007f36959db10e in do_begin () from /opt/vertica/R/lib/libR.so
#44 0x00007f36959d864c in Rf_eval () from /opt/vertica/R/lib/libR.so
#45 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#46 0x00007f36959d8964 in Rf_eval () from /opt/vertica/R/lib/libR.so
#47 0x00007f36959db10e in do_begin () from /opt/vertica/R/lib/libR.so
#48 0x00007f36959d864c in Rf_eval () from /opt/vertica/R/lib/libR.so
#49 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#50 0x00007f36959d8964 in Rf_eval () from /opt/vertica/R/lib/libR.so
#51 0x00007f36959dce14 in do_eval () from /opt/vertica/R/lib/libR.so
#52 0x00007f36959e2c44 in bcEval () from /opt/vertica/R/lib/libR.so
#53 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#54 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so

---Type to continue, or q to quit---
#55 0x00007f36959d8964 in Rf_eval () from /opt/vertica/R/lib/libR.so
#56 0x00007f36959d80bc in forcePromise () from /opt/vertica/R/lib/libR.so
#57 0x00007f36959ecaea in FORCE_PROMISE () from /opt/vertica/R/lib/libR.so
#58 0x00007f36959ecc0a in getvar () from /opt/vertica/R/lib/libR.so
#59 0x00007f36959e108d in bcEval () from /opt/vertica/R/lib/libR.so
#60 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#61 0x00007f36959d80bc in forcePromise () from /opt/vertica/R/lib/libR.so
#62 0x00007f36959ecaea in FORCE_PROMISE () from /opt/vertica/R/lib/libR.so
#63 0x00007f36959ecc0a in getvar () from /opt/vertica/R/lib/libR.so
#64 0x00007f36959e108d in bcEval () from /opt/vertica/R/lib/libR.so
#65 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#66 0x00007f36959d80bc in forcePromise () from /opt/vertica/R/lib/libR.so
#67 0x00007f36959ecaea in FORCE_PROMISE () from /opt/vertica/R/lib/libR.so
#68 0x00007f36959ecc0a in getvar () from /opt/vertica/R/lib/libR.so
#69 0x00007f36959e108d in bcEval () from /opt/vertica/R/lib/libR.so
#70 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#71 0x00007f36959d80bc in forcePromise () from /opt/vertica/R/lib/libR.so
#72 0x00007f36959ecaea in FORCE_PROMISE () from /opt/vertica/R/lib/libR.so
#73 0x00007f36959ecc0a in getvar () from /opt/vertica/R/lib/libR.so
#74 0x00007f36959e108d in bcEval () from /opt/vertica/R/lib/libR.so
#75 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#76 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#77 0x00007f36959e2a1b in bcEval () from /opt/vertica/R/lib/libR.so
#78 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#79 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#80 0x00007f36959e2a1b in bcEval () from /opt/vertica/R/lib/libR.so
#81 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#82 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#83 0x00007f36959e2a1b in bcEval () from /opt/vertica/R/lib/libR.so
#84 0x00007f36959d8275 in Rf_eval () from /opt/vertica/R/lib/libR.so
#85 0x00007f36959d957c in Rf_applyClosure () from /opt/vertica/R/lib/libR.so
#86 0x00007f36959d8964 in Rf_eval () from /opt/vertica/R/lib/libR.so
#87 0x00007f3695054f85 in Rcpp::Evaluator::run(SEXPREC_, SEXPREC_) () from /opt/vertica/R/library/Rcpp/lib/libRcpp.so
#88 0x00007f369505517d in Rcpp::Evaluator::run(SEXPREC*) () from /opt/vertica/R/library/Rcpp/lib/libRcpp.so
#89 0x00007f3695055195 in Rcpp::internal::try_catch(SEXPREC*) () from /opt/vertica/R/library/Rcpp/lib/libRcpp.so
#90 0x00000000005241df in Vertica::VerticaRInterface::processPartitionForR(RInside&, UDxSideProcessServerInterface&, Vertica::PartitionReader&, Vertica::PartitionWriter&, std::string const&, std::string const&) ()
#91 0x00000000004d9b#0 0x00002b7f4a4b1594 in R_gc_internal (size_needed=0) at memory.c:1514


backtrace on the forum: http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-January/003335.html
#0 0x00002b7f4a4b1594 in R_gc_internal (size_needed=0) at memory.c:1514
#1 0x00002b7f4a4b34da in Rf_mkPROMISE (expr=0xf0dbf0f8, rho=0x904dab0) at memory.c:2165
#2 0x00002b7f4a470e04 in Rf_promiseArgs (el=0xf0dbf0c0, rho=0x904dab0) at eval.c:1961
#3 0x00002b7f4a479fc3 in Rf_eval (e=0xa3936a0, rho=0x904dab0) at eval.c:525
#4 0x00002b7f4a47a90a in do_eval (call=0xa376c98, op=0x903d058, args=0xa38f2c0, rho=0xa38f100) at eval.c:2082
#5 0x00002b7f4a4bc63e in do_internal (call=, op=, args=, env=0xa38f100) at names.c:1227
#6 0x00002b7f4a47a139 in Rf_eval (e=0xa376c28, rho=0xa38f100) at eval.c:482
#7 0x00002b7f4a47e678 in Rf_applyClosure (call=0xa393780, op=0xa3786e8, arglist=0xa3914b0, rho=0xa3ea258, suppliedenv=0x904dae8) at eval.c:838
#8 0x00002b7f4a479feb in Rf_eval (e=0xa393780, rho=0xa3ea258) at eval.c:526
#9 0x00002b7f4a47fbee in forcePromise (e=0xa3938d0) at eval.c:331
#10 0x00002b7f4a47a373 in Rf_eval (e=0x907a5e8, rho=0xa3939b0) at eval.c:436
#11 0x00002b7f4a47b8ad in do_return (call=0xa37cea0, op=, args=0x2b7f4a610f18, rho=0xa3939b0) at eval.c:1437
#12 0x00002b7f4a47a139 in Rf_eval (e=0xa37cea0, rho=0xa3939b0) at eval.c:482
#13 0x00002b7f4a47fbee in forcePromise (e=0xa3928a8) at eval.c:331
#14 0x00002b7f4a47a373 in Rf_eval (e=0x907a5e8, rho=0xa390e58) at eval.c:436
#15 0x00002b7f4a47b942 in do_begin (call=0xa37c848, op=0x9025d70, args=0x2b7f4a610f18, rho=0xa390e58) at eval.c:1420
#16 0x00002b7f4a47a139 in Rf_eval (e=0xa37c848, rho=0xa390e58) at eval.c:482
#17 0x00002b7f4a47e678 in Rf_applyClosure (call=0xa37cdf8, op=0xa393a20, arglist=0xa392918, rho=0xa3939b0, suppliedenv=0x904dae8) at eval.c:838
#18 0x00002b7f4a479feb in Rf_eval (e=0xa37cdf8, rho=0xa3939b0) at eval.c:526
#19 0x00002b7f4a47cbd7 in do_set (call=0xa37cd18, op=0x9025f68, args=0xa37cd50, rho=0xa3939b0) at eval.c:1722
#20 0x00002b7f4a47a139 in Rf_eval (e=0xa37cd18, rho=0xa3939b0) at eval.c:482
#21 0x00002b7f4a47b942 in do_begin (call=0xa3c84f8, op=0x9025d70, args=0x2b7f4a610f18, rho=0xa3939b0) at eval.c:1420
#22 0x00002b7f4a47a139 in Rf_eval (e=0xa3c84f8, rho=0xa3939b0) at eval.c:482
#23 0x00002b7f4a47e678 in Rf_applyClosure (call=0xa393828, op=0xa3e1940, arglist=0xa393908, rho=0xa3ea258, suppliedenv=0x904dae8) at eval.c:838
#24 0x00002b7f4a479feb in Rf_eval (e=0xa393828, rho=0xa3ea258) at eval.c:526
#25 0x00002b7f4f69affc in Rcpp::Evaluator::run (expr=0xa3936a0, env=0x904dab0) at Evaluator.cpp:36
#26 0x00002b7f4f69b201 in Rcpp::Evaluator::run (expr=0xa3936a0) at Evaluator.cpp:58
#27 0x00002b7f4f69b219 in Rcpp::internal::try_catch (expr=0xa3936a0) at Evaluator.cpp:78
#28 0x00002b7f4f4522f8 in rcpp_hello_world (rlen=)

@eddelbuettel
Copy link
Member

Jeebus. The stack trace is mostly useless.

Submit reproducible examples.

Better still, consult list archives, SO, other Rcpp documentation, ... and just create it as a very, very, very, very long list. Convert that to a data.frame in R.

The current Date.Frame class needs a rewrite. Volunteers welcome.

@tmanka
Copy link
Author

tmanka commented Jan 14, 2015

Hi Dirk,

Let me work on that. Thank you for pointing me in the right direction.

Thanks,
Ted

@eddelbuettel
Copy link
Member

No worries. The rcpp-devel list a great resource, please consider subscribing there and carrying the discussion over. It will get you more eyeballs.

@kevinushey
Copy link
Contributor

As a workaround, consider building an Rcpp::List and manually turning it into a data.frame at the end, e.g.

// [[Rcpp::export]]
List list_as_df(List x) {
    R_xlen_t nrows = Rf_length(x[0]);
    x.attr("row.names") = IntegerVector::create(NA_INTEGER, nrows);
    x.attr("class") = "data.frame";
    return x;
}

A more robust implementation would handle edge cases (zero length list; list with differing number of rows; and so on...)

jackwasey pushed a commit to jackwasey/icd that referenced this issue Jan 21, 2015
@coatless
Copy link
Contributor

Probably should add this into the known issue section... I'm thinking about also mentioning at the same time that Rcpp::List can be used to get around the imposed 20 item limited DF ctor.

@github-actions
Copy link

This issue is stale (365 days without activity) and will be closed in 31 days unless new activity is seen. Please feel free to re-open it is still a concern, possibly with additional data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants