Discussion:
[Rcpp-devel] ___assert_rtn warning with package check
Jason Serviss
2018-06-13 11:05:10 UTC
Permalink
Hello everyone,

I am currently in the process of trying to utilise C++ via Rcpp, RcppEigen, and RcppArmadillo in a package for the first time. I am experiencing the following on running devtools::check() with the package:


checking compiled code ... WARNING
File ‘check/libs/check.so’:
Found ‘___assert_rtn’, possibly from ‘assert’ (C)
Object: ‘RcppExports.o’


I found a similar problem previously discussed (here: http://rcpp-devel.r-forge.r-project.narkive.com/yc1h8bf6/rcppeigen-package-skeleton-r-cmd-check-warning) some time ago although, in this case, it seemed to be system specific. Based on the comments, I created a minimal reproducible example (here: https://github.com/jasonserviss/check) and automated the build with TravisCI (build report here: https://travis-ci.org/jasonserviss/check/builds/391685256).

I have noticed two things:

1) there are 2 functions in the package, function “a" and function “b”, if I remove function “b” I no longer receive the warning. Despite this, there wouldn’t, to my eyes, seem to be anything extremely unusual about function “b”.

2) If I remove RcppArmadillo from the LinkingTo section in the DESCRIPTION file I, again, no longer receive the warning. I am aware of the fact that, in the example, there is no need to link to RcppArmadillo although, in the real use case, there is.

Id be very appreciative if anyone here could help me get an understanding for this warning and how it can be resolved!

Kind Regards,
Jason Serviss
Qiang Kou
2018-06-13 13:51:43 UTC
Permalink
Hi, Jason,

The assert is from RcppEigen.

I think the reason is how "NDEBUG" is handled by Armadillo.

In your package, the RcppArmadillo header is included before RcppEigen:
https://github.com/jasonserviss/check/blob/master/src/RcppExports.cpp#L4

In RcppArmadillo:

https://github.com/RcppCore/RcppArmadillo/blob/master/inst/include/RcppArmadilloConfig.h#L92-L94

The NDEBUG has been undefined.

Then in RcppEigen:

https://github.com/RcppCore/RcppEigen/blob/master/inst/include/Eigen/src/Core/util/Macros.h#L549

The assert will be used if NDEBUG has been undefined.

I hope this answers your question.

Best wishes,

KK
Post by Jason Serviss
Hello everyone,
I am currently in the process of trying to utilise C++ via Rcpp,
RcppEigen, and RcppArmadillo in a package for the first time. I am
Found ‘___assert_rtn’, possibly from ‘assert’ (C)
Object: ‘RcppExports.o’
http://rcpp-devel.r-forge.r-project.narkive.com/yc1h8bf6/
rcppeigen-package-skeleton-r-cmd-check-warning) some time ago although,
in this case, it seemed to be system specific. Based on the comments, I
created a minimal reproducible example (here: https://github.com/
jasonserviss/check) and automated the build with TravisCI (build report
here: https://travis-ci.org/jasonserviss/check/builds/391685256).
1) there are 2 functions in the package, function “a" and function “b”, if
I remove function “b” I no longer receive the warning. Despite this, there
wouldn’t, to my eyes, seem to be anything extremely unusual about function
“b”.
2) If I remove RcppArmadillo from the LinkingTo section in the DESCRIPTION
file I, again, no longer receive the warning. I am aware of the fact that,
in the example, there is no need to link to RcppArmadillo although, in the
real use case, there is.
Id be very appreciative if anyone here could help me get an understanding
for this warning and how it can be resolved!
Kind Regards,
Jason Serviss
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Jason Serviss
2018-06-15 10:56:49 UTC
Permalink
Qiang,

Sorry for the late reply (somehow your reply ended up in the Junk folder). Switching RcppArmadillo and RcppEigen in the LinkingTo section (and thus the header order) did not help BUT your mention of NDEBUG lead me to this Githuhb issue: https://github.com/RcppCore/RcppArmadillo/issues/116. The addition of a similar file in the inst folder (see change log at the bottom of the issue) with #define NDEBUG 1 and then adding the file as an import in RcppExports.cpp did the trick. Unfortunately, running compileAttributes() locally overwrites the manual changes in RcppExports.cpp but, for now, I guess I will have to live with this. Thanks a lot for your input!

Kind Regards,
Jason




On 13 Jun 2018, at 15:51, Qiang Kou <***@qkou.info<mailto:***@qkou.info>> wrote:

Hi, Jason,

The assert is from RcppEigen.

I think the reason is how "NDEBUG" is handled by Armadillo.

In your package, the RcppArmadillo header is included before RcppEigen: https://github.com/jasonserviss/check/blob/master/src/RcppExports.cpp#L4<https://mailfilter.sunet.se/canit/urlproxy.php?_q=aHR0cHM6Ly9naXRodWIuY29tL2phc29uc2Vydmlzcy9jaGVjay9ibG9iL21hc3Rlci9zcmMvUmNwcEV4cG9ydHMuY3BwI0w0&_s=amFzb24uc2Vydmlzc0BraS5zZQ%3D%3D&_c=fdecf48f&_r=a2ktc2U%3D>

In RcppArmadillo:

https://github.com/RcppCore/RcppArmadillo/blob/master/inst/include/RcppArmadilloConfig.h#L92-L94<https://mailfilter.sunet.se/canit/urlproxy.php?_q=aHR0cHM6Ly9naXRodWIuY29tL1JjcHBDb3JlL1JjcHBBcm1hZGlsbG8vYmxvYi9tYXN0ZXIvaW5zdC9pbmNsdWRlL1JjcHBBcm1hZGlsbG9Db25maWcuaCNMOTItTDk0&_s=amFzb24uc2Vydmlzc0BraS5zZQ%3D%3D&_c=cf8cff17&_r=a2ktc2U%3D>

The NDEBUG has been undefined.

Then in RcppEigen:

https://github.com/RcppCore/RcppEigen/blob/master/inst/include/Eigen/src/Core/util/Macros.h#L549<https://mailfilter.sunet.se/canit/urlproxy.php?_q=aHR0cHM6Ly9naXRodWIuY29tL1JjcHBDb3JlL1JjcHBFaWdlbi9ibG9iL21hc3Rlci9pbnN0L2luY2x1ZGUvRWlnZW4vc3JjL0NvcmUvdXRpbC9NYWNyb3MuaCNMNTQ5&_s=amFzb24uc2Vydmlzc0BraS5zZQ%3D%3D&_c=4af01d3b&_r=a2ktc2U%3D>

The assert will be used if NDEBUG has been undefined.

I hope this answers your question.

Best wishes,

KK


On Wed, Jun 13, 2018 at 7:05 AM, Jason Serviss <***@ki.se<mailto:***@ki.se>> wrote:
Hello everyone,

I am currently in the process of trying to utilise C++ via Rcpp, RcppEigen, and RcppArmadillo in a package for the first time. I am experiencing the following on running devtools::check() with the package:


checking compiled code ... WARNING
File ‘check/libs/check.so’:
Found ‘___assert_rtn’, possibly from ‘assert’ (C)
Object: ‘RcppExports.o’


I found a similar problem previously discussed (here: http://rcpp-devel.r-forge.r-project.narkive.com/yc1h8bf6/rcppeigen-package-skeleton-r-cmd-check-warning<https://mailfilter.sunet.se/canit/urlproxy.php?_q=aHR0cDovL3JjcHAtZGV2ZWwuci1mb3JnZS5yLXByb2plY3QubmFya2l2ZS5jb20veWMxaDhiZjYvcmNwcGVpZ2VuLXBhY2thZ2Utc2tlbGV0b24tci1jbWQtY2hlY2std2FybmluZw%3D%3D&_s=amFzb24uc2Vydmlzc0BraS5zZQ%3D%3D&_c=f9d02bc5&_r=a2ktc2U%3D>) some time ago although, in this case, it seemed to be system specific. Based on the comments, I created a minimal reproducible example (here: https://github.com/jasonserviss/check<https://mailfilter.sunet.se/canit/urlproxy.php?_q=aHR0cHM6Ly9naXRodWIuY29tL2phc29uc2Vydmlzcy9jaGVjaw%3D%3D&_s=amFzb24uc2Vydmlzc0BraS5zZQ%3D%3D&_c=fd24f0d8&_r=a2ktc2U%3D>) and automated the build with TravisCI (build report here: https://travis-ci.org/jasonserviss/check/builds/391685256<https://mailfilter.sunet.se/canit/urlproxy.php?_q=aHR0cHM6Ly90cmF2aXMtY2kub3JnL2phc29uc2Vydmlzcy9jaGVjay9idWlsZHMvMzkxNjg1MjU2&_s=amFzb24uc2Vydmlzc0BraS5zZQ%3D%3D&_c=717fbb88&_r=a2ktc2U%3D>).

I have noticed two things:

1) there are 2 functions in the package, function “a" and function “b”, if I remove function “b” I no longer receive the warning. Despite this, there wouldn’t, to my eyes, seem to be anything extremely unusual about function “b”.

2) If I remove RcppArmadillo from the LinkingTo section in the DESCRIPTION file I, again, no longer receive the warning. I am aware of the fact that, in the example, there is no need to link to RcppArmadillo although, in the real use case, there is.

Id be very appreciative if anyone here could help me get an understanding for this warning and how it can be resolved!

Kind Regards,
Jason Serviss


_______________________________________________
Rcpp-devel mailing list
Rcpp-***@lists.r-forge.r-project.org<mailto:Rcpp-***@lists.r-forge.r-project.org>
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel<https://mailfilter.sunet.se/canit/urlproxy.php?_q=aHR0cHM6Ly9saXN0cy5yLWZvcmdlLnItcHJvamVjdC5vcmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3JjcHAtZGV2ZWw%3D&_s=amFzb24uc2Vydmlzc0BraS5zZQ%3D%3D&_c=07a68f11&_r=a2ktc2U%3D>
Dirk Eddelbuettel
2018-06-15 11:38:20 UTC
Permalink
On 15 June 2018 at 10:56, Jason Serviss wrote:
| Qiang,
|
| Sorry for the late reply (somehow your reply ended up in the Junk folder). Switching RcppArmadillo and RcppEigen in the LinkingTo section (and thus the header order) did not help BUT your mention of NDEBUG lead me to this Githuhb issue: https://github.com/RcppCore/RcppArmadillo/issues/116. The addition of a similar file in the inst folder (see change log at the bottom of the issue) with #define NDEBUG 1 and then adding the file as an import in RcppExports.cpp did the trick. Unfortunately, running compileAttributes() locally overwrites the manual changes in RcppExports.cpp but, for now, I guess I will have to live with this. Thanks a lot for your input!

Re-read the Rcpp Attributes vignette more carefully. There are way to have a
header file auto-included, one way is to name the same as your package but
append _types.h -- ie RcppGSL has inst/include/RcppGSL_types.h.

No need for manual updates then.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Loading...