helske / crashtest Goto Github PK
View Code? Open in Web Editor NEWTrying to debug pointer problems
Trying to debug pointer problems
I get segfault when I repeatedly build the model. Valgrind reports:
[1] "iteration 1"
[1] "first model"
[1] "create matrices"
[1] "second model"
[1] "rebuild first model"
[1] "repeat millstein function 100,000 times"
[1] "iteration 2"
[1] "first model"
[1] "create matrices"
[1] "second model"
[1] "rebuild first model"
[1] "repeat millstein function 100,000 times"
[1] "iteration 3"
[1] "first model"
[1] "create matrices"
[1] "second model"
[1] "rebuild first model"
[1] "repeat millstein function 100,000 times"
==26398== Jump to the invalid address stated on the next line
==26398== at 0x1DD75010: ???
==26398== by 0x4F7D026: R_RunWeakRefFinalizer (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F7D213: ??? (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F4A679: Rf_eval (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F4EA11: ??? (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F4AB99: Rf_eval (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F4D723: ??? (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F4AA9F: Rf_eval (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F4CABE: ??? (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F42F67: ??? (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F50D55: ??? (in /usr/lib/R/lib/libR.so)
==26398== by 0x4F512FF: ??? (in /usr/lib/R/lib/libR.so)
==26398== Address 0x1dd75010 is not stack'd, malloc'd or (recently) free'd
==26398==
*** caught segfault ***
address 0x1dd75010, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
==26398==
==26398== Process terminating with default action of signal 11 (SIGSEGV)
==26398== at 0x547451D: raise (raise.c:53)
==26398== by 0x547466F: ??? (in /lib/x86_64-linux-gnu/libpthread-2.24.so)
==26398== by 0x1DD7500F: ???
==26398==
==26398== HEAP SUMMARY:
==26398== in use at exit: 259,162,338 bytes in 28,465 blocks
==26398== total heap usage: 315,728 allocs, 287,263 frees, 1,311,929,706 bytes allocated
==26398==
==26398== LEAK SUMMARY:
==26398== definitely lost: 0 bytes in 0 blocks
==26398== indirectly lost: 0 bytes in 0 blocks
==26398== possibly lost: 0 bytes in 0 blocks
==26398== still reachable: 259,162,338 bytes in 28,465 blocks
==26398== of which reachable via heuristic:
==26398== newarray : 4,264 bytes in 1 blocks
==26398== suppressed: 0 bytes in 0 blocks
==26398== Reachable blocks (those to which a pointer was found) are not shown.
==26398== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==26398==
==26398== For counts of detected and suppressed errors, rerun with: -v
==26398== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
Script, not minimal but does the job:
library(crashtest)
simulate.data <- function(Tn=10, x0=1, sigma_x=1, sigma_y=1, mu=0, dt=1) {
x <- x0
y <- rep(NA,Tn)
for (k in 1:Tn) {
x <- x*exp((mu-0.5*sigma_x^2)*dt + sqrt(dt) * rnorm(1, sd=sigma_x))
y[k] <- rnorm(1, mean=log(x), sd=sigma_y)
}
return(y)
}
set.seed(834)
n <- 50
y <- simulate.data(n, mu = 0.05, sigma_x = 0.2, sigma_y = 1)
for (i in 1:10) {
print(paste0("iteration ", i))
Rcpp::sourceCpp("sde_functions1.cpp", rebuild = TRUE)
pntrs <- create_pntrs()
# this seems to be crucial, altough looks to be irrelevant. Probably triggers gc at some point?
print("create matrices")
a <- matrix(1000^2, 1000, 1000)
print("repeat millstein function 100,000 times")
for (j in 1:100000)
out <- milstein(1, 4, 1, c(0.05, 0.2, 1), pntrs$drift, pntrs$diffusion, pntrs$ddiffusion, TRUE, 1)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.