Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCrash in RStudio (not in R) when calling testFormat #25
Comments
|
I tend to run much newer RStudio previews but they behave. Just to narrow this down as I have the same 64-bit platform: RStudio Server or Desktop? |
|
I can replicate this. Will take a look. |
|
@kevinushey I am at a loss. We have a hard crash with RStudio (including 1.0.106) with a piece of code that works fine on the command-line. As @bobjansen found, executing this in RStudio bombs. I added a bunch of Is this possibly a bad Boost interaction? I am building via BH which is still at 1.60.0-2. |
|
For reference here is the function as I currently have it, which includes two small and minor fixes relative to what GH has: // [[Rcpp::export]]
Rcpp::NumericVector testFormat(const std::string fmt, const std::string s, const std::string tz = "") {
REprintf("A0\n");
bt::ptime pt, ptbase;
REprintf("A1\n");
std::istringstream is(s);
REprintf("A2\n");
std::locale loc = std::locale(std::locale::classic(), new bt::time_input_facet(fmt));
#if 0
REprintf("A3\n");
is.imbue(loc);
is >> pt;
#endif
REprintf("A4\n");
double timeval = (pt == ptbase) ? NA_REAL : ptToDouble(pt);
REprintf("A5\n");
Rcpp::NumericVector pv(1);
REprintf("A6\n");
pv[0] = timeval;
REprintf("A7\n");
pv.attr("class") = Rcpp::CharacterVector::create("POSIXct", "POSIXt");
pv.attr("tzone") = tz;
REprintf("A8\n");
return pv;
}Moving the |
|
Interestingly, I'm not able to replicate this initially on OS X. I'll see if I can on an Ubuntu VM. |
|
Yes, Bob and I are both on 16.04. I can try some RStudio Server installation on some of the blades here to see if it makes a difference. |
|
I can replicate the crash. Do we have a rocker + RStudio container where we can run against a version of R + anytime build with sanitizers that could potentially shed more light here? |
|
Rocker + Sanitizers, yes (now also via rhub (!!)) and I used that recently because this very package was UBSAN flagged. But not with RStudio. But I guess you could just add the RStudio binary? |
|
BTW the package itself is now UBSAN clean -- or so I think. The pages at CRAN are all from the 0.0.3 version and don't seem to have been updated to the now-current 0.0.4 version: https://cloud.r-project.org/web/checks/check_results_anytime.html |
|
This looks really really gnarly. I moved a things around, tried via instantiation of the local What Boost version are you building against, @kevinushey ? Could that be the issue? |
|
Here's what I see in RStudio with
The error seems to indicate that the crash is occurring when attempting to construct a |
|
My best hypothesis: some cross-talk between the version of Boost used by RStudio (a very old 1.50.0) and the version used by |
|
Also note that since RStudio links to Boost statically, there's almost surely some awkward cross-talk going on. This is a tough place to be since |
|
Boost Date_time has been used header-only for several years now via the (underused) RcppBDT package. There is a anytime does the same, and its core functionality worked so far. This one is a real stunner. @jjallaire mentioned a trick to me some years ago about 'protecting' the namespace away via |
How do I query from C++ code whether I am inside RStudio? I will for now just disable the function and return NA and a warning (maybe via `Rcpp::stop()). |
|
The simplest way to check if you're within RStudio (or an RStudio sub-process) is by checking the |
|
Does that work on Windoze? |
|
Hmm, to my surprise checking |
|
Yeah, just fought that for a moment in the Windows VM as well. Using Could you register this issue internally? To the best of my knowledge this is the first time Boost has been biting our heads off. |
|
Actually that makes everything easier because I just have to access a boolean in a local environment. |
|
Ok, I have a fudge. I actually just renamed that C++ function by appending |
|
@bobjansen Please give the current master branch a spin. While it does not "fix" the underlying issue -- which is likely an extremely rare and hairy Boost interaction between two different pieces of software built with two different Boost versions, namely RStudio and anytime, it at least avoids taking down your machine. |
|
Correction: It was still in a branch when I wrote this 30 minutes ago. Will merge to master now. |
do not call testFormat() in RStudio (closes #25)
|
@eddelbuettel I gave current master a spin and it works as expected. |
|
It is far from perfect -- but also the first (known to me) time that Boost is biting. We will have to keep an eye on it. Not crashing is a first step. Thanks again for bringing this up. |
I'm on:
If I run
RStudio (Version 0.99.903) crashes immediately but R ran from the command line does not.
My first hypothesis is that memory corruption happens in
anytimein a way that only causes problems when thersessionis started like RStudio does and will try to confirm.