PolMine / RcppCWB

'Rcpp' Bindings for the 'Corpus Workbench' (CWB)
Other
2 stars 3 forks source link

Memory leaks #59

Open ablaette opened 2 years ago

ablaette commented 2 years ago

When I run sanitizers on RcppCWB with rocker/r-devel-ubsan-clang, this is an example of what I see:

Indirect leak of 2 byte(s) in 1 object(s) allocated from:
    #0 0x498164 in malloc (/usr/local/lib/R/bin/exec/R+0x498164)
    #1 0xffffa1fa5300 in cl_malloc (/usr/local/lib/R/site-library/00LOCK-RcppCWB/00new/RcppCWB/libs/RcppCWB.so+0xf6300)
    #2 0xffffa1f9361c in define_macro (/usr/local/lib/R/site-library/00LOCK-RcppCWB/00new/RcppCWB/libs/RcppCWB.so+0xe461c)
    #3 0xffffa1f9382c in init_macros (/usr/local/lib/R/site-library/00LOCK-RcppCWB/00new/RcppCWB/libs/RcppCWB.so+0xe482c)
    #4 0xffffa1f78954 in initialize_cqp (/usr/local/lib/R/site-library/00LOCK-RcppCWB/00new/RcppCWB/libs/RcppCWB.so+0xc9954)
    #5 0xffffa1f6dda0 in init_cqp() /tmp/RtmpjTMBry/R.INSTALL3d965fba81b/RcppCWB/src/cqp.cpp:45:2
    #6 0xffffa1f2defc in _RcppCWB_init_cqp_try() /tmp/RtmpjTMBry/R.INSTALL3d965fba81b/RcppCWB/src/RcppExports.cpp:1556:5
    #7 0xffffa1f2db70 in _RcppCWB_init_cqp /tmp/RtmpjTMBry/R.INSTALL3d965fba81b/RcppCWB/src/RcppExports.cpp:1564:27
    #8 0xffffb6bd0830 in R_doDotCall /tmp/R-devel/src/main/dotcode.c:598:17
    #9 0xffffb6d468f4 in bcEval /tmp/R-devel/src/main/eval.c:7692:21
    #10 0xffffb6d2c4a8 in Rf_eval /tmp/R-devel/src/main/eval.c:748:8
    #11 0xffffb6d8c12c in R_execClosure /tmp/R-devel/src/main/eval.c
    #12 0xffffb6d88b74 in Rf_applyClosure /tmp/R-devel/src/main/eval.c:1844:16
    #13 0xffffb6d4b2b8 in bcEval /tmp/R-devel/src/main/eval.c:7104:12
    #14 0xffffb6d2c4a8 in Rf_eval /tmp/R-devel/src/main/eval.c:748:8
    #15 0xffffb6d8c12c in R_execClosure /tmp/R-devel/src/main/eval.c
    #16 0xffffb6d88b74 in Rf_applyClosure /tmp/R-devel/src/main/eval.c:1844:16
    #17 0xffffb6d4b2b8 in bcEval /tmp/R-devel/src/main/eval.c:7104:12
    #18 0xffffb6d2c4a8 in Rf_eval /tmp/R-devel/src/main/eval.c:748:8
    #19 0xffffb6d8c12c in R_execClosure /tmp/R-devel/src/main/eval.c
    #20 0xffffb6d88b74 in Rf_applyClosure /tmp/R-devel/src/main/eval.c:1844:16
    #21 0xffffb6d4b2b8 in bcEval /tmp/R-devel/src/main/eval.c:7104:12
    #22 0xffffb6d2c4a8 in Rf_eval /tmp/R-devel/src/main/eval.c:748:8
    #23 0xffffb6d8c12c in R_execClosure /tmp/R-devel/src/main/eval.c
    #24 0xffffb6d88b74 in Rf_applyClosure /tmp/R-devel/src/main/eval.c:1844:16
    #25 0xffffb6d4b2b8 in bcEval /tmp/R-devel/src/main/eval.c:7104:12
    #26 0xffffb6d2c4a8 in Rf_eval /tmp/R-devel/src/main/eval.c:748:8
    #27 0xffffb6d86378 in forcePromise /tmp/R-devel/src/main/eval.c:568:8
    #28 0xffffb6db4828 in FORCE_PROMISE /tmp/R-devel/src/main/eval.c:5157:15
    #29 0xffffb6db4828 in getvar /tmp/R-devel/src/main/eval.c:5198:14
    #30 0xffffb6d596a8 in bcEval /tmp/R-devel/src/main/eval.c:6888:20

This is the summary:

SUMMARY: AddressSanitizer: 470137 byte(s) leaked in 647 allocation(s).
ablaette commented 2 years ago

Could not reconstruct what I did in march. As I could not install valgrind on my M1 mac, I ran things in a rocker-Docker container (rocker/r-devel-ubsan-clang) on an Intel Mac. First I ran R CMD check, cd'd into the check dir, then:

R -d "valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes -s" -f RcppCWB-Ex.R

This yields the most extensive error report. I do not see anything serious, but obviously there are memory leaks.