[R-pkg-devel] Warnings related to functions from the survival package

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Thu Oct 31 21:06:06 CET 2024


On Thu, 31 Oct 2024 17:59:01 +0100
Tomas Kalibera <tomas.kalibera using gmail.com> wrote:

> for now, if you know an elegant, minimal way how to suppress
> this, and have the time and energy, a patch would be welcome

A fresh R-4.4.2 build compiled with clang-19 -fsanitize=function gives
the error:

$ bin/R -q -s -e 'library(survival); survdiff(Surv(futime, fustat) ~ rx,data=ovarian)'
dotcode.c:2008:2: runtime error: call to function survdiff2 through pointer to incorrect function type 'void (*)(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *)'
/tmp/RtmpW0SC00/R.INSTALL5d1b3402d0c5/survival/src/survdiff2.c:10: note: survdiff2 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior dotcode.c:2008:2 

A suppression file will avoid the error without patching R:

$ cat dotcode.supp 
function:dotcode.c

or more fine-grained:

$ cat dotcode.supp
function:do_dotCode

$ UBSAN_OPTIONS="suppressions=$(realpath dotcode.supp)" bin/R -q -s -e 'library(survival); survdiff(Surv(futime, fustat) ~ rx,data=ovarian)'
Call:
survdiff(formula = Surv(futime, fustat) ~ rx, data = ovarian)
<and so on>

Alternatively, the following patch will also suppress the error:

--- src/main/dotcode.c     2024-03-26 23:02:08.000000000 +0000
+++ src/main/dotcode.c  2024-10-31 19:53:36.272334541 +0000
@@ -1658,6 +1658,9 @@
 #define FILL 0xee
 #define NG 64
 
+#ifdef __clang__
+__attribute__((no_sanitize("function")))
+#endif
 attribute_hidden SEXP do_dotCode(SEXP call, SEXP op, SEXP args, SEXP env)
 {
     void **cargs, **cargs0 = NULL /* -Wall */;

I hope I understood you correctly that you're looking for a tested
workaround.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list