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 upAbort on R type error if debugging #860
Conversation
| Rf_type2char(TYPEOF(x)), | ||
| Rf_type2char(RTYPE)); | ||
| abort(); | ||
| #elif |
kevinushey
Jun 5, 2018
Contributor
#else instead of #elif?
#else instead of #elif?
jackwasey
Jun 5, 2018
Author
Contributor
Yes... whoops. But it worked with clang, so I missed it.
Yes... whoops. But it worked with clang, so I missed it.
Codecov Report
@@ Coverage Diff @@
## master #860 +/- ##
======================================
Coverage 90.3% 90.3%
======================================
Files 70 70
Lines 3261 3261
======================================
Hits 2945 2945
Misses 316 316
Continue to review full report at Codecov.
|
| @@ -67,9 +67,17 @@ namespace Rcpp { | |||
| default: | |||
| const char* fmt = "Not compatible with requested type: " | |||
| "[type=%s; target=%s]."; | |||
| #ifndef NDEBUG | |||
| fprintf(stderr, | |||
eddelbuettel
Jun 7, 2018
Member
Should that not be REprintf() ?
Should that not be REprintf() ?
jackwasey
Jun 7, 2018
Author
Contributor
I wasn't aware of REprintf, made the change.
I used the following to test:
Rcpp::cppFunction('void type_err(IntegerVector iv) {}')
type_err("a")
Which aborts with the appropriate error message if I add -UNDEBUG in CXXFLAGS before compilation, otherwise gives normal Rcpp behavior.
I wasn't aware of REprintf, made the change.
I used the following to test:
Rcpp::cppFunction('void type_err(IntegerVector iv) {}')
type_err("a")
Which aborts with the appropriate error message if I add -UNDEBUG in CXXFLAGS before compilation, otherwise gives normal Rcpp behavior.
eddelbuettel
Jun 7, 2018
Member
Thanks. REprintf() is one of those gems hidden away in WRE which "they" to nag you on submission. You know, like 'no stdout, no abort, ...' ;-)
Thanks. REprintf() is one of those gems hidden away in WRE which "they" to nag you on submission. You know, like 'no stdout, no abort, ...' ;-)
Following discussion in #857 , this PR prints an error to standard error, and aborts, allowing a debugger to examine state leading up to the error, instead of dropping out of R. The
assertmacro didn't seem like the right tool, as it would never give an informative error message. The glibcassertmacro callsabort, so I used it here, while checking for absence ofNDEBUG. The default build process in R is done with-DNDEBUGso this should not alter behavior for anyone who hasn't explicitly used-UNDEBUG, and therefore this should not impact any packages built for CRAN in the usual way.There is no obvious way for me to add an automated test for this code, since it requires compiling with and without the
NDEBUGflag set.