Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-07 Thread Iñaki Ucar
Thanks all. My summary here differs a bit though: 1. The point that a longjump does not necessarily represent an error is crucial here. That's the rationale behind Lionel's implementation of this exception. My understanding then is that client packages should *never ever* catch it, and thus it

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Kevin Ushey
Thanks, I think I understand the issue better now. Ultimately, it comes down to the fact that UnwindProtect doesn't really allow handling of R conditions in the "regular" way as e.g. tryCatch() does; instead, it gives us just enough to properly unwind the C++ stack when an R error occurs. If I can

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Dirk Eddelbuettel
On 7 February 2022 at 00:12, Jeroen Ooms wrote: | I have pushed a new version of V8 to CRAN that wraps the R callbacks | in another tryCatch() such that we do not make any assumptions on the | sort of exception handing provided by Rcpp. This should unblock you if | you want to move forward on

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Jeroen Ooms
I have pushed a new version of V8 to CRAN that wraps the R callbacks in another tryCatch() such that we do not make any assumptions on the sort of exception handing provided by Rcpp. This should unblock you if you want to move forward on this change. On Sun, Feb 6, 2022 at 9:30 PM Lionel Henry

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Dirk Eddelbuettel
To sum up: ¯\_(ツ)_/¯ I have no bone in this fight. Leaving it as is works for me too. Dirk -- https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Jeroen Ooms
On Sun, Feb 6, 2022 at 6:25 PM Kevin Ushey wrote: > > If I tweak your example package code so that all exceptions are caught via a > catch (...) {} block, I can see something like: > > > uptest::uptest() > Error in (function () : Ouch from R > Caught some other exception. > > The fact that

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Kevin Ushey
And I'm seeing you pointed that out at the end of the README... so yes, we should probably just have our exception inherit from std::exception. On Sun, Feb 6, 2022 at 9:31 AM Dirk Eddelbuettel wrote: > > On 6 February 2022 at 18:18, Jeroen Ooms wrote: > | Well not really, this kind of misses my

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Dirk Eddelbuettel
On 6 February 2022 at 18:18, Jeroen Ooms wrote: | Well not really, this kind of misses my point that it the | unwind-protect makes it impossible to meaningfully catch the R error | in C++, handle it, and continue running the C++ code, without aborting | the entire mission and throwing the user

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Kevin Ushey
If I tweak your example package code so that all exceptions are caught via a catch (...) {} block, I can see something like: > uptest::uptest() Error in (function () : Ouch from R Caught some other exception. The fact that we're still printing the R error message seems undesirable, but it looks

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Kevin Ushey
Is it possible the issue here is ultimately just that our LongjumpException class doesn't inherit from std::exception? On Sun, Feb 6, 2022 at 9:18 AM Jeroen Ooms wrote: > On Sun, Feb 6, 2022 at 5:56 PM Dirk Eddelbuettel wrote: > > > > > > On 6 February 2022 at 17:40, Jeroen Ooms wrote: > > |

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Jeroen Ooms
On Sun, Feb 6, 2022 at 5:56 PM Dirk Eddelbuettel wrote: > > > On 6 February 2022 at 17:40, Jeroen Ooms wrote: > | We can try to take V8 out of the equation, and see what actually > | causes the change. V8 uses (and tests!) the Rcpp feature to call an R > | function from C++. This behaves quite

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Dirk Eddelbuettel
On 6 February 2022 at 17:40, Jeroen Ooms wrote: | We can try to take V8 out of the equation, and see what actually | causes the change. V8 uses (and tests!) the Rcpp feature to call an R | function from C++. This behaves quite differently when using | RCPP_UNWIND_PROTECT. | | Here is a dummy

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Jeroen Ooms
We can try to take V8 out of the equation, and see what actually causes the change. V8 uses (and tests!) the Rcpp feature to call an R function from C++. This behaves quite differently when using RCPP_UNWIND_PROTECT. Here is a dummy package to demonstrate this: https://github.com/jeroen/uptest

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-01 Thread Dirk Eddelbuettel
Lionel, Thanks a bunch for the prompt and detailed reply. CCing Jeroen now, I think I had poked him over DM on this but not followed. Easy for us to delegate to V8 :) That is of course a complicated (and toolchain-dependent) package too so we shall see what we can do there. But the good news on

[Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-01-31 Thread Iñaki Ucar
Hi Lionel, I've been setting this for years in my own packages, and particularly in a simulator that greatly benefits from this due to its heavy usage of R calls from the C++ simulation loop. Now, we're looking into setting this feature on by default in the next release of Rcpp to improve the