Skip to content

[Rcpp-devel] Rcpp code in my package causes the R process to crash on fedora-clang

4 messages · Venelin Mitov, Dirk Eddelbuettel, Alexis Sarda

#
Dear Rcpp-devel list,

I was forwarded to this list after posting the same question on the
R-help list.

In an e-mail received yesterday from a member of the CRAN maintainer
team, I was informed that one of my
packages, PCMBaseCpp (https://CRAN.R-project.org/package=PCMBaseCpp),
is going to be removed from CRAN on April 4th,
due to an R-process crash during unit-tests on the fedora-clang
flavour. The problem is the following:

1. All PCMBaseCpp unit-tests pass on all CRAN flavours except
r-devel-linux-x86_64-fedora-clang.
2. Running devtools::check_rhub(): succeeds on all platforms including
fedora-clang. Hence, I've no way to reproduce the error.
3. The line of code that is causing a segfault error and a crash of
the R-process is a call to the
std::logic_error() constructor. This line of code is found in the package's file
src/QuadraticPoly.h:

throw logic_error(oss.str());

4. However, throwing the above exception is correct - the
exception is intercepted (caught) at a higher functional level of the
PCMBaseCpp package, where it is handled. The same line of code is
executed without problem on all other flavours.

5. Hence, my question is why std::logic_error(oss.str()) is
throwing a memory allocation exception on this specific CRAN flavour?

I couldn't find anywhere in the R extension manual a text stating that
it is illegal to create std::logic_error objects in C++ code. The
fact that the same code is passing on all other flavours including
rhub's fedora-clang suggests that this might be a local problem in the
fedora-clang test environment on CRAN.

Any advice on how I should proceed to prevent the package getting
removed from CRAN?

For you information, here is the stacktrace generated using gdb:

Best regards,
Venelin MITOV
#
On 22 March 2020 at 17:30, Venelin Mitov wrote:
| 3. The line of code that is causing a segfault error and a crash of
| the R-process is a call to the
| std::logic_error() constructor. This line of code is found in the package's file
| src/QuadraticPoly.h:
| 
| throw logic_error(oss.str());

I always recommend to Rcpp::stop() which I use extensively and almost exclusively.
 
| 4. However, throwing the above exception is correct - the
| exception is intercepted (caught) at a higher functional level of the
| PCMBaseCpp package, where it is handled. The same line of code is
| executed without problem on all other flavours.
| 
| 5. Hence, my question is why std::logic_error(oss.str()) is
| throwing a memory allocation exception on this specific CRAN flavour?

I have no idea.

But excception handling is genuinely complicated. Feel free to peruse the old
issue ticket and pull request discussions at the Rcpp repo at GitHub -- there
is lots of it.

| I couldn't find anywhere in the R extension manual a text stating that
| it is illegal to create std::logic_error objects in C++ code. The

You missed that (at least parts of) R Core does not want us to use C++ in the
first place -- or that is how one could read the (still somewhat
"controversial" blog post [1]).

| fact that the same code is passing on all other flavours including
| rhub's fedora-clang suggests that this might be a local problem in the
| fedora-clang test environment on CRAN.
| 
| Any advice on how I should proceed to prevent the package getting
| removed from CRAN?

Just because "it should work in theory" simply does not mean it will in
practice.  If a CRAN test machine consistently shows errors, I most often try
to change my code [2].  You could at least try that.

A sad aspect in all this also is that we have no publically accessible
machine behaving exactly like that Fedora box.
 
| For you information, here is the stacktrace generated using gdb:

No there wasn't.

Standard GNU mailman mailing list setup so attachments are stripped.

Dirk

[1] http://developer.r-project.org/Blog/public/2019/03/28/use-of-c---in-packages/index.html
[2] There are exceptions. I think the errors against anytime are a setup
issue at their end as it genuinely happens nowhere else.
#
Thanks for your quick response, Dirk!

Concise and informative as usual.

Best,
Venelin

Am So., 22. März 2020 um 17:57 Uhr schrieb Dirk Eddelbuettel <edd at debian.org>:

  
    
#
FWIW, I have the same problem, which is what I reported here:

https://github.com/RcppCore/Rcpp/issues/972#issuecomment-593291723

I haven't been able to solve it because I can't reproduce it (I don't have
a Mac, and the Docker container with that R setup doesn't fail).

In my case, it could be that the exception pointer ends up being null, like
in this unrelated issue I found:

https://github.com/dart-lang/sdk/issues/38141

But until I get access to a Mac, I won't be sure.

Regards,
Alexis.
On Sun, Mar 22, 2020, 18:41 Venelin Mitov <vmitov at gmail.com> wrote:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20200323/4b0f4a6e/attachment-0001.html>