Cleanup stack parsing / demangling #598
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main cause of the errors was the logic at https://github.com/RcppCore/Rcpp/compare/master...jimhester:cppstack?expand=1#diff-f885be769bd30163f6d49bcfa6246690L44. If there was no
+
in the stack tracefind_last_of()
would returnstd::string::npos (-1)
and resizing to-2
is obviously an error.Some compiler versions return the stack trace in slightly different formats, so this error was only apparent with older gcc compilers. I modified the logic to retain more information (now only the demangled name is fixed, the rest of the information remains) and it should also be more robust to future formatting changes.
This was not noticed in previous releases because stack traces were only enabled if the
Rcpp::exception()
was constructed with a file and line. In #582 I modified the default constructor to also include the cpp stack trace, which revealed this bug. Also as noted my tests for the exception code did not include use ofRcpp::stop()
and this bug did not occur with standard expectations and direct call ofRcpp::exception()
. We now have an explicit test usingRcpp::stop()
as well.Fixes #596 and possibly #593 although that is as yet untested.