-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
two (short) new entries for Rcpp-FAQ vignette #1009
Conversation
vignettes/rmd/Rcpp-FAQ.Rmd
Outdated
|
||
## Can we use exceptions and stop() across shared libraries? | ||
|
||
No, sadly. A known limitation coming from the operating system, Windows in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might in it's present form be too cautionary. In all Rcpp attribute generated code (including the export of C++ interfaces to other packages) we handle this gracefully. The only place I'm aware of in Rcpp where this bites is specifically in Rcpp Module methods on Windows only. I think we might be better off just adding docs to modules saying you can't call stop() from within methods (they should always return something even if just an error object).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I thought we still bound by the general restriction of not being able to throw/catch across distinct DLLs? But maybe I am indeed to pessimistic in that view as it would blow up the use case of, eg, RQuantLib catching QuantLib errors.
Easy to rewrite as "Mostly. A known remaining limitation ..." I can take a stab at it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross-DLL exceptions work as long as:
- You are linking to a non-static C++ standard library;
- You are using the same standard library in all compiled objects.
Unfortunately, 1. is not true on Windows as R opts to link to libstdc++ statically; there was some discussion about whether this could be changed for Rtools 4.0 but it sounds like that won't happen.
In some cases, 2. is also not true -- e.g. on macOS users might end up mixing the version of libc++ bundled with R in some dylibs, and the system version of libc++ in others. Usually this means that the exception type info isn't properly handled across module boundaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and of course, Rcpp attributes help us as, if one calls an attributes-generated function, any C++ exceptions are effectively shielded by try-catch and so are not propagated into a separate DLL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jjallaire @kevinushey Thanks for the very helpful comments.
I just rebased and force-pushed this branch adding one refining commit. The diff in the commit now shows an expanded and refined answer to this new FAQ entry based on your comments.
I'm not sure about the RQuantLib case but I'd say given we haven't really
heard about this save for modules that perhaps there is some other
mediation in place there?
…On Mon, Oct 28, 2019 at 7:38 AM Dirk Eddelbuettel ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In vignettes/rmd/Rcpp-FAQ.Rmd
<#1009 (comment)>:
> @@ -1720,3 +1737,11 @@ elsewhere.
So if your autogenerated file fails, and a `symbols not found` error is reported
by the linker, consider running `compileAttributes()` twice. Deleting
`R/RcppExports.R` and `src/RcppExports.cpp` may also work.
+
+## Can we use exceptions and stop() across shared libraries?
+
+No, sadly. A known limitation coming from the operating system, Windows in
Hm, I thought we still bound by the general restriction of not being able
to throw/catch across distinct DLLs? But maybe I am indeed to pessimistic
in that view as it would blow up the use case of, eg, RQuantLib catching
QuantLib errors.
Easy to rewrite as "Mostly. A known remaining limitation ..." I can take a
stab at it later.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1009?email_source=notifications&email_token=AAAZPRYG7ST25WCAF43AQ43QQ3FNDA5CNFSM4JFY4WA2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCJMHYYI#discussion_r339518406>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAZPR5PQMRTEEXLWRS24QLQQ3FNDANCNFSM4JFY4WAQ>
.
|
Yes I meant that in general it just works (at least on not-on-Windows). I.e. at work we have a large-ish standard C++ codebase, exceptions are generally forbidden and it asserts and exits on error so for the calling-from-R-case I redefine these as Rcpp::stop() and it works just fine. Just not sure about Windows which I have the benefit of mostly not seeing anymore .... |
2e62d19
to
8a2c83d
Compare
8a2c83d
to
05a1d51
Compare
Codecov Report
@@ Coverage Diff @@
## master #1009 +/- ##
=======================================
Coverage 82.46% 82.46%
=======================================
Files 63 63
Lines 3166 3166
=======================================
Hits 2611 2611
Misses 555 555 Continue to review full report at Codecov.
|
@kevinushey @jjallaire if/when you have a chance glance over the current state of the new paragraphs and especially the updated / rewritten second one reflecting your really useful feedback. Otherwise looks like we are good to go. May toss this at CRAN soon as 1.0.3. |
Ok, I will take "no further comment" in the generous sense of "no further complaints" 😀 Merging now and going to prepare a 1.0.3 release. |
Two simple additions which provide a start.
@kevinushey @jjallaire if you have comments / extensions maybe commit straight into branch?