[R-pkg-devel] Segfaults on R-devel
Claborne, Daniel
d@n|e|@c|@borne @end|ng |rom pnn|@gov
Tue Jul 9 00:46:32 CEST 2024
Seemingly starting with the most recent builds of R-devel, I�ve been getting segfaults related to a piece of cpp code that indexes a zero-size NumericVector. Essentially the same as this dummy example:
```
library(Rcpp)
sourceCpp(
code = '
#include<Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector zeroindex() {
NumericVector zerosize(0);
Rcout << zerosize[0] << std::endl;
return zerosize;
}
'
)
zeroindex()
```
On R-release and on previous builds, this returns something like:
```
6.92674e-310
numeric(0)
```
But on current R-devel containers:
```
*** caught segfault ***
address 0x1, cause 'memory not mapped'
Traceback:
1: .Call(<pointer: 0x7fa9369c7930>)
2: zeroindex()
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
```
It was easy enough to write a catch for the zero-size vector, however I�m wondering why the discrepancy between R-devel and previous versions?
Best,
-DMC
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list