Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valgrind sees a small leak #8

Closed
eddelbuettel opened this issue Aug 18, 2022 · 6 comments
Closed

Valgrind sees a small leak #8

eddelbuettel opened this issue Aug 18, 2022 · 6 comments

Comments

@eddelbuettel
Copy link
Owner

Thanks to a heads-up by Ivan on the r-package-devel list, we actually have an open issue with valgrind I was unaware of:
https://www.stats.ox.ac.uk/pub/bdr/memtests/valgrind/dtts/tests/tinytest.Rout

Time permitting, I will try to drill down a little and see if I can isolate it.

@eddelbuettel
Copy link
Owner Author

Looks like this goes away when we just remove the (redundant, as Rcpp's compileAttributes() adds them too) try and catch blocks in three or four of the functions in src/align.cpp.

I see a residual error from valgrind for 362 bytes coming from data.table and forder. I am running a pre-release version here so that may influence it, it may also happen with the CRAN version.

@eddelbuettel
Copy link
Owner Author

The residual leak reported from e.g. a simple call R -d valgrind -f tests/tinytest.R is

==1554274== 
==1554274== HEAP SUMMARY:
==1554274==     in use at exit: 103,548,075 bytes in 20,708 blocks
==1554274==   total heap usage: 89,578 allocs, 68,870 frees, 227,959,910 bytes allocated
==1554274== 
==1554274== 352 bytes in 1 blocks are possibly lost in loss record 156 of 2,209
==1554274==    at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1554274==    by 0x40147D9: calloc (rtld-malloc.h:44)
==1554274==    by 0x40147D9: allocate_dtv (dl-tls.c:375)
==1554274==    by 0x40147D9: _dl_allocate_tls (dl-tls.c:634)
==1554274==    by 0x4DAF834: allocate_stack (allocatestack.c:430)
==1554274==    by 0x4DAF834: pthread_create@@GLIBC_2.34 (pthread_create.c:647)
==1554274==    by 0x578E1EF: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==1554274==    by 0x5784A10: GOMP_parallel (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==1554274==    by 0x11F3B5B9: forder (in /usr/local/lib/R/site-library/data.table/libs/datatable.so)
==1554274==    by 0x4946693: ??? (in /usr/lib/R/lib/libR.so)
==1554274==    by 0x498A97A: ??? (in /usr/lib/R/lib/libR.so)
==1554274==    by 0x496BC17: Rf_eval (in /usr/lib/R/lib/libR.so)
==1554274==    by 0x497420E: ??? (in /usr/lib/R/lib/libR.so)
==1554274==    by 0x496B967: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==1554274==    by 0x4991DB4: ??? (in /usr/lib/R/lib/libR.so)
==1554274== 
==1554274== LEAK SUMMARY:
==1554274==    definitely lost: 0 bytes in 0 blocks
==1554274==    indirectly lost: 0 bytes in 0 blocks
==1554274==      possibly lost: 352 bytes in 1 blocks
==1554274==    still reachable: 103,547,723 bytes in 20,707 blocks
==1554274==                       of which reachable via heuristic:
==1554274==                         newarray           : 4,264 bytes in 1 blocks
==1554274==         suppressed: 0 bytes in 0 blocks
==1554274== Reachable blocks (those to which a pointer was found) are not shown.
==1554274== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1554274== 
==1554274== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

@eddelbuettel
Copy link
Owner Author

eddelbuettel commented Aug 21, 2022

Turns out that upgrading to the current state (i.e. 'dev' 0.14.3 as at its repo) of data.table changes things again:

==1639739== Memcheck, a memory error detector
==1639739== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1639739== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1639739== Command: /usr/lib/R/bin/exec/R -f tests/tinytest.R
==1639739== 

R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> pkg <- "dtts"
> 
> if (requireNamespace("tinytest", quietly=TRUE)) {
+     tinytest::test_package(pkg)
+ }

test_dtts.R...................    0 tests    
test_dtts.R...................    0 tests    
test_dtts.R...................    0 tests    
test_dtts.R...................    0 tests    
test_dtts.R...................    0 tests    
test_dtts.R...................    0 tests    
test_dtts.R...................    0 tests    
test_dtts.R...................    0 tests    
test_dtts.R...................    1 tests �[0;32mOK�[0m 
test_dtts.R...................    1 tests �[0;32mOK�[0m 
test_dtts.R...................    1 tests �[0;32mOK�[0m 
test_dtts.R...................    2 tests �[0;32mOK�[0m 
test_dtts.R...................    2 tests �[0;32mOK�[0m 
test_dtts.R...................    2 tests �[0;32mOK�[0m 
test_dtts.R...................    3 tests �[0;32mOK�[0m 
test_dtts.R...................    3 tests �[0;32mOK�[0m 
test_dtts.R...................    3 tests �[0;32mOK�[0m ==1639739== Conditional jump or move depends on uninitialised value(s)
==1639739==    at 0x127BE0D5: align_idx_duration(Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&) (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x127B3F22: _dtts_align_idx_duration (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x4946693: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x49470F4: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x4983965: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496BC17: Rf_eval (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x497420E: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496B967: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496BD49: Rf_eval (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x4973B57: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496C026: Rf_eval (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x497420E: ??? (in /usr/lib/R/lib/libR.so)
==1639739== 

test_dtts.R...................    4 tests �[0;32mOK�[0m 
test_dtts.R...................    4 tests �[0;32mOK�[0m 
test_dtts.R...................    4 tests �[0;32mOK�[0m 
test_dtts.R...................    5 tests �[0;32mOK�[0m 
test_dtts.R...................    5 tests �[0;32mOK�[0m 
test_dtts.R...................    5 tests �[0;32mOK�[0m 
test_dtts.R...................    6 tests �[0;32mOK�[0m 
test_dtts.R...................    6 tests �[0;32mOK�[0m 
test_dtts.R...................    6 tests �[0;32mOK�[0m 
test_dtts.R...................    7 tests �[0;32mOK�[0m 
test_dtts.R...................    7 tests �[0;32mOK�[0m 
test_dtts.R...................    7 tests �[0;32mOK�[0m 
test_dtts.R...................    8 tests �[0;32mOK�[0m 
test_dtts.R...................    8 tests �[0;32mOK�[0m 
test_dtts.R...................    8 tests �[0;32mOK�[0m 
test_dtts.R...................    9 tests �[0;32mOK�[0m 
test_dtts.R...................    9 tests �[0;32mOK�[0m 
test_dtts.R...................    9 tests �[0;32mOK�[0m 
test_dtts.R...................   10 tests �[0;32mOK�[0m 
test_dtts.R...................   10 tests �[0;32mOK�[0m 
test_dtts.R...................   10 tests �[0;32mOK�[0m 
test_dtts.R...................   11 tests �[0;32mOK�[0m 
test_dtts.R...................   12 tests �[0;32mOK�[0m 
test_dtts.R...................   13 tests �[0;32mOK�[0m 
test_dtts.R...................   14 tests �[0;32mOK�[0m 
test_dtts.R...................   15 tests �[0;32mOK�[0m 
test_dtts.R...................   16 tests �[0;32mOK�[0m 
test_dtts.R...................   16 tests �[0;32mOK�[0m 
test_dtts.R...................   16 tests �[0;32mOK�[0m 
test_dtts.R...................   16 tests �[0;32mOK�[0m 
test_dtts.R...................   16 tests �[0;32mOK�[0m 
test_dtts.R...................   16 tests �[0;32mOK�[0m 
test_dtts.R...................   17 tests �[0;32mOK�[0m 
test_dtts.R...................   17 tests �[0;32mOK�[0m 
test_dtts.R...................   17 tests �[0;32mOK�[0m 
test_dtts.R...................   17 tests �[0;32mOK�[0m 
test_dtts.R...................   17 tests �[0;32mOK�[0m 
test_dtts.R...................   17 tests �[0;32mOK�[0m 
test_dtts.R...................   17 tests �[0;32mOK�[0m 
test_dtts.R...................   18 tests �[0;32mOK�[0m 
test_dtts.R...................   18 tests �[0;32mOK�[0m 
test_dtts.R...................   18 tests �[0;32mOK�[0m 
test_dtts.R...................   18 tests �[0;32mOK�[0m 
test_dtts.R...................   18 tests �[0;32mOK�[0m 
test_dtts.R...................   18 tests �[0;32mOK�[0m 
test_dtts.R...................   18 tests �[0;32mOK�[0m 
test_dtts.R...................   19 tests �[0;32mOK�[0m 
test_dtts.R...................   19 tests �[0;32mOK�[0m 
test_dtts.R...................   19 tests �[0;32mOK�[0m 
test_dtts.R...................   19 tests �[0;32mOK�[0m 
test_dtts.R...................   19 tests �[0;32mOK�[0m 
test_dtts.R...................   19 tests �[0;32mOK�[0m 
test_dtts.R...................   19 tests �[0;32mOK�[0m 
test_dtts.R...................   20 tests �[0;32mOK�[0m 
test_dtts.R...................   20 tests �[0;32mOK�[0m 
test_dtts.R...................   20 tests �[0;32mOK�[0m 
test_dtts.R...................   20 tests �[0;32mOK�[0m 
test_dtts.R...................   20 tests �[0;32mOK�[0m 
test_dtts.R...................   20 tests �[0;32mOK�[0m 
test_dtts.R...................   20 tests �[0;32mOK�[0m 
test_dtts.R...................   21 tests �[0;32mOK�[0m 
test_dtts.R...................   21 tests �[0;32mOK�[0m 
test_dtts.R...................   21 tests �[0;32mOK�[0m 
test_dtts.R...................   21 tests �[0;32mOK�[0m 
test_dtts.R...................   21 tests �[0;32mOK�[0m 
test_dtts.R...................   21 tests �[0;32mOK�[0m 
test_dtts.R...................   21 tests �[0;32mOK�[0m 
test_dtts.R...................   22 tests �[0;32mOK�[0m 
test_dtts.R...................   22 tests �[0;32mOK�[0m 
test_dtts.R...................   22 tests �[0;32mOK�[0m 
test_dtts.R...................   22 tests �[0;32mOK�[0m 
test_dtts.R...................   22 tests �[0;32mOK�[0m 
test_dtts.R...................   22 tests �[0;32mOK�[0m 
test_dtts.R...................   22 tests �[0;32mOK�[0m 
test_dtts.R...................   23 tests �[0;32mOK�[0m 
test_dtts.R...................   24 tests �[0;32mOK�[0m 
test_dtts.R...................   25 tests �[0;32mOK�[0m 
test_dtts.R...................   26 tests �[0;32mOK�[0m 
test_dtts.R...................   27 tests �[0;32mOK�[0m 
test_dtts.R...................   28 tests �[0;32mOK�[0m 
test_dtts.R...................   29 tests �[0;32mOK�[0m 
test_dtts.R...................   30 tests �[0;32mOK�[0m 
test_dtts.R...................   31 tests �[0;32mOK�[0m 
test_dtts.R...................   31 tests �[0;32mOK�[0m 
test_dtts.R...................   31 tests �[0;32mOK�[0m 
test_dtts.R...................   32 tests �[0;32mOK�[0m 
test_dtts.R...................   32 tests �[0;32mOK�[0m 
test_dtts.R...................   32 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m 
test_dtts.R...................   33 tests �[0;32mOK�[0m ==1639739== Source and destination overlap in memcpy_chk(0x4d18b24, 0x4d18b20, 55)
==1639739==    at 0x48539B2: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1639739==    by 0x4ADDA1E: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496A3AF: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496C98D: Rf_errorcall (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496CC3F: Rf_error (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x48C8B16: R_GetCCallable (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x127BCB77: align_func_duration(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const*, unsigned long, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const*, unsigned long, Rcpp::Vector<19, Rcpp::PreserveStorage>, nanotime::ConstPseudoVector<14, double, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&, nanotime::ConstPseudoVector<14, double, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&, nanotime::ConstPseudoVector<10, int, int> const&, nanotime::ConstPseudoVector<10, int, int> const&, Rcpp::Function_Impl<Rcpp::PreserveStorage> const&) (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x127BDB28: align_duration(Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&, Rcpp::Function_Impl<Rcpp::PreserveStorage>) (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x127B480D: _dtts_align_duration (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x4946651: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x49470F4: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x4983965: ??? (in /usr/lib/R/lib/libR.so)
==1639739== 
Error in .align_duration_cpp(x[[1]], sort(y), x, start, end, sopen, eopen,  : 
  function 'CsubsetDT' not provided by package 'data.table'
Calls: <Anonymous> ... .local -> data.table -> do.call -> .align_duration_cpp
Execution halted
==1639739== 
==1639739== HEAP SUMMARY:
==1639739==     in use at exit: 98,828,594 bytes in 19,905 blocks
==1639739==   total heap usage: 78,200 allocs, 58,295 frees, 193,149,257 bytes allocated
==1639739== 
==1639739== LEAK SUMMARY:
==1639739==    definitely lost: 0 bytes in 0 blocks
==1639739==    indirectly lost: 0 bytes in 0 blocks
==1639739==      possibly lost: 0 bytes in 0 blocks
==1639739==    still reachable: 98,828,594 bytes in 19,905 blocks
==1639739==                       of which reachable via heuristic:
==1639739==                         newarray           : 4,264 bytes in 1 blocks
==1639739==         suppressed: 0 bytes in 0 blocks
==1639739== Reachable blocks (those to which a pointer was found) are not shown.
==1639739== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1639739== 
==1639739== Use --track-origins=yes to see where uninitialised values come from
==1639739== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==1639739== 
==1639739== 1 errors in context 1 of 2:
==1639739== Source and destination overlap in memcpy_chk(0x4d18b24, 0x4d18b20, 55)
==1639739==    at 0x48539B2: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1639739==    by 0x4ADDA1E: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496A3AF: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496C98D: Rf_errorcall (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496CC3F: Rf_error (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x48C8B16: R_GetCCallable (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x127BCB77: align_func_duration(std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const*, unsigned long, std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const*, unsigned long, Rcpp::Vector<19, Rcpp::PreserveStorage>, nanotime::ConstPseudoVector<14, double, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&, nanotime::ConstPseudoVector<14, double, std::chrono::duration<long, std::ratio<1l, 1000000000l> > > const&, nanotime::ConstPseudoVector<10, int, int> const&, nanotime::ConstPseudoVector<10, int, int> const&, Rcpp::Function_Impl<Rcpp::PreserveStorage> const&) (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x127BDB28: align_duration(Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&, Rcpp::Function_Impl<Rcpp::PreserveStorage>) (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x127B480D: _dtts_align_duration (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x4946651: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x49470F4: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x4983965: ??? (in /usr/lib/R/lib/libR.so)
==1639739== 
==1639739== 
==1639739== 1 errors in context 2 of 2:
==1639739== Conditional jump or move depends on uninitialised value(s)
==1639739==    at 0x127BE0D5: align_idx_duration(Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&, Rcpp::Vector<10, Rcpp::PreserveStorage> const&) (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x127B3F22: _dtts_align_idx_duration (in /usr/local/lib/R/site-library/dtts/libs/dtts.so)
==1639739==    by 0x4946693: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x49470F4: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x4983965: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496BC17: Rf_eval (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x497420E: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496B967: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496BD49: Rf_eval (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x4973B57: ??? (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x496C026: Rf_eval (in /usr/lib/R/lib/libR.so)
==1639739==    by 0x497420E: ??? (in /usr/lib/R/lib/libR.so)
==1639739== 
==1639739== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

More work to do ...

PS And while Writing R Extensions muses that the 'unconditional jump' may be from compiler optimzations and suggests building without optimizations, doing so (as a test) for both data.table and dtts makes no difference.

@eddelbuettel
Copy link
Owner Author

I'll reopen as while #9 is in and does not hurt, it did nuttin' on the valgrind issue.

@lsilvest
Copy link
Collaborator

I have tracked down the lines that cause the issue:

t1 <- seq(nanotime("2021-02-01 00:00:00 America/New_York"), nanotime("2021-04-01 00:00:00 America/New_York"),
          by=as.nanoduration("01:00:00"))
dt1 <- data.table(index=t1, V1=1:length(t1))
setkey(dt1, index)

To create the error, the setkey has to be there. I then get what you were getting in your first attempt (I'm running data.table 1.14.8):

==1148931== 
==1148931== HEAP SUMMARY:
==1148931==     in use at exit: 77,726,746 bytes in 16,560 blocks
==1148931==   total heap usage: 58,464 allocs, 41,904 frees, 147,295,448 bytes allocated
==1148931== 
==1148931== 336 bytes in 1 blocks are possibly lost in loss record 142 of 2,024
==1148931==    at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1148931==    by 0x40147D9: calloc (rtld-malloc.h:44)
==1148931==    by 0x40147D9: allocate_dtv (dl-tls.c:375)
==1148931==    by 0x40147D9: _dl_allocate_tls (dl-tls.c:634)
==1148931==    by 0x4DA9834: allocate_stack (allocatestack.c:430)
==1148931==    by 0x4DA9834: pthread_create@@GLIBC_2.34 (pthread_create.c:647)
==1148931==    by 0x57881EF: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==1148931==    by 0x577EA10: GOMP_parallel (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==1148931==    by 0x1272FF40: forder (forder.c:486)
==1148931==    by 0x4952AF3: ??? (in /usr/lib/R/lib/libR.so)
==1148931==    by 0x49938BD: ??? (in /usr/lib/R/lib/libR.so)
==1148931==    by 0x49A98EF: Rf_eval (in /usr/lib/R/lib/libR.so)
==1148931==    by 0x49AB48E: ??? (in /usr/lib/R/lib/libR.so)
==1148931==    by 0x49AC2D4: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==1148931==    by 0x4999A2F: ??? (in /usr/lib/R/lib/libR.so)
==1148931== 
==1148931== LEAK SUMMARY:
==1148931==    definitely lost: 0 bytes in 0 blocks
==1148931==    indirectly lost: 0 bytes in 0 blocks
==1148931==      possibly lost: 336 bytes in 1 blocks
==1148931==    still reachable: 77,726,410 bytes in 16,559 blocks
==1148931==                       of which reachable via heuristic:
==1148931==                         newarray           : 4,264 bytes in 1 blocks
==1148931==         suppressed: 0 bytes in 0 blocks
==1148931== Reachable blocks (those to which a pointer was found) are not shown.
==1148931== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1148931== 
==1148931== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

By not using the seq function, this issue is avoided:

t1 <- nanotime(1:10 * one_second_duration)
dt1 <- data.table(index=t1, V1=1:length(t1))
setkey(dt1, index)

The above gives:

==1148963== 
==1148963== HEAP SUMMARY:
==1148963==     in use at exit: 77,859,049 bytes in 16,561 blocks
==1148963==   total heap usage: 58,471 allocs, 41,910 frees, 147,065,138 bytes allocated
==1148963== 
==1148963== LEAK SUMMARY:
==1148963==    definitely lost: 0 bytes in 0 blocks
==1148963==    indirectly lost: 0 bytes in 0 blocks
==1148963==      possibly lost: 0 bytes in 0 blocks
==1148963==    still reachable: 77,859,049 bytes in 16,561 blocks
==1148963==                       of which reachable via heuristic:
==1148963==                         newarray           : 4,264 bytes in 1 blocks
==1148963==         suppressed: 0 bytes in 0 blocks
==1148963== Reachable blocks (those to which a pointer was found) are not shown.
==1148963== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1148963== 
==1148963== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Will take an in-depth look at the nanotime seq function vs. the nanotime constructor, in conjunction with the setkey. It doesn't look at any rate to be something in dtts. That said, I have found with a valgrind memcheck that we do have an uninitialized memory read for which I have a fix that I will commit once I've done a bit more testing.

@eddelbuettel
Copy link
Owner Author

We appear to have forgotten to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants