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

[BUGZILLA #17692] Memory leak error after calling parallel::stopCluster(< fork cluster >) #6866

Open
MichaelChirico opened this issue May 19, 2020 · 6 comments

Comments

@MichaelChirico
Copy link
Owner

Reproducing the error

  1. Start a fresh R session as follows:
R --vanilla --debugger=valgrind --debugger-args="--track-origins=yes"
  1. Enter the following code
library(parallel)
cl <- makeForkCluster(2)
stopCluster(cl)
  1. This is the output I obtained
stopCluster(cl)
==19491== 
==19491== HEAP SUMMARY:
==19491==     in use at exit: 42,714,551 bytes in 10,727 blocks
==19491==   total heap usage: 23,102 allocs, 12,375 frees, 66,151,484 bytes
allocated
==19491== 
==19489== 
==19489== HEAP SUMMARY:
==19489==     in use at exit: 43,008,035 bytes in 10,825 blocks
==19489==   total heap usage: 23,209 allocs, 12,384 frees, 66,513,006 bytes
allocated
==19489== 
==19491== LEAK SUMMARY:
==19491==    definitely lost: 0 bytes in 0 blocks
==19491==    indirectly lost: 0 bytes in 0 blocks
==19491==      possibly lost: 0 bytes in 0 blocks
==19491==    still reachable: 42,714,551 bytes in 10,727 blocks
==19491==                       of which reachable via heuristic:
==19491==                         newarray           : 4,264 bytes in 1
blocks
==19491==         suppressed: 0 bytes in 0 blocks
==19491== Rerun with --leak-check=full to see details of leaked memory
==19491== 
==19491== For counts of detected and suppressed errors, rerun with: -v
==19491== ERROR SUMMARY: 704 errors from 8 contexts (suppressed: 0 from 0)
==19489== LEAK SUMMARY:
==19489==    definitely lost: 0 bytes in 0 blocks
==19489==    indirectly lost: 0 bytes in 0 blocks
==19489==      possibly lost: 0 bytes in 0 blocks
==19489==    still reachable: 43,008,035 bytes in 10,825 blocks
==19489==                       of which reachable via heuristic:
==19489==                         newarray           : 4,264 bytes in 1
blocks
==19489==         suppressed: 0 bytes in 0 blocks
==19489== Rerun with --leak-check=full to see details of leaked memory
==19489== 
==19489== For counts of detected and suppressed errors, rerun with: -v
==19489== ERROR SUMMARY: 704 errors from 8 contexts (suppressed: 0 from 0)

# Session info

sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
[9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods  
[8] base     

loaded via a namespace (and not attached):
[1] compiler_3.6.2

METADATA

  • Bug author - George Vega
  • Creation time - 2020-01-14 22:02:21 UTC
  • Bugzilla link
  • Status - VERIFIED WORKSFORME
  • Alias - None
  • Component - Low-level
  • Version - R 3.6.xx
  • Hardware - x86_64/x64/amd64 (64-bit) Linux-Ubuntu
  • Importance - P5 major
  • Assignee - R-core
  • URL -
  • Modification time - 2020-01-16 10:02 UTC
@MichaelChirico
Copy link
Owner Author

Are you certain these are not red herrings? Just starting and exiting R (without doing anything with parallel) is qualitatively similar in terms of the valgrind summary:

==5050==
==5050== HEAP SUMMARY:
==5050== in use at exit: 40,391,651 bytes in 9,121 blocks
==5050== total heap usage: 20,150 allocs, 11,029 frees, 62,826,845 bytes allocated
==5050==
==5050== LEAK SUMMARY:
==5050== definitely lost: 0 bytes in 0 blocks
==5050== indirectly lost: 0 bytes in 0 blocks
==5050== possibly lost: 0 bytes in 0 blocks
==5050== still reachable: 40,391,651 bytes in 9,121 blocks
==5050== of which reachable via heuristic:
==5050== newarray : 4,264 bytes in 1 blocks
==5050== suppressed: 0 bytes in 0 blocks
==5050== Rerun with --leak-check=full to see details of leaked memory
==5050==
==5050== For counts of detected and suppressed errors, rerun with: -v
==5050== ERROR SUMMARY: 46 errors from 1 contexts (suppressed: 0 from 0)


METADATA

  • Comment author - Benjamin Tyner
  • Timestamp - 2020-01-15 01:23:02 UTC

@MichaelChirico
Copy link
Owner Author

There is some memory still reachable after R shuts down, which will be freed by the operating system, so it does not cause any trouble. Looking at

R -d "valgrind --leak-check=full --show-leak-kinds=all" -e "q()"

so, no cluster at all, the memory is mostly fragments of the R heap (which will include heap unused by live R objects at that point), cache in serialization, the symbol table, ICU data (statically cached collator), cache of primitive methods for dispatch, connections for stdin/stdout/stderr, registered routines in DLLs and external symbols, dynamically linked objects using dlopen(), etc. Arranging for all of this memory to be explicitly freed at shutdown of R would be a lot of work and complicate the code substantially, it is not worth the effort and added cognitive complexity as the memory will be freed by the OS right away.

R is not special in this, note it is common that there is "still reachable" memory at program shutdown (try basic tools from binutils,...).


METADATA

  • Comment author - Tomas Kalibera
  • Timestamp - 2020-01-15 09:11:56 UTC

@MichaelChirico
Copy link
Owner Author

(In reply to Benjamin Tyner from comment #1)

Are you certain these are not red herrings? Just starting and exiting R
(without doing anything with parallel) is qualitatively similar in terms of
the valgrind summary:

==5050== 
==5050== HEAP SUMMARY:
==5050==     in use at exit: 40,391,651 bytes in 9,121 blocks
==5050==   total heap usage: 20,150 allocs, 11,029 frees, 62,826,845 bytes
allocated
==5050== 
==5050== LEAK SUMMARY:
==5050==    definitely lost: 0 bytes in 0 blocks
==5050==    indirectly lost: 0 bytes in 0 blocks
==5050==      possibly lost: 0 bytes in 0 blocks
==5050==    still reachable: 40,391,651 bytes in 9,121 blocks
==5050==                       of which reachable via heuristic:
==5050==                         newarray           : 4,264 bytes in 1 blocks
==5050==         suppressed: 0 bytes in 0 blocks
==5050== Rerun with --leak-check=full to see details of leaked memory
==5050== 
==5050== For counts of detected and suppressed errors, rerun with: -v
==5050== ERROR SUMMARY: 46 errors from 1 contexts (suppressed: 0 from 0)

Yes, that is the message I obtain before even running sessionInfo(). After quitting R session I get another valgrind summary.


METADATA

  • Comment author - George Vega
  • Timestamp - 2020-01-15 19:18:52 UTC

@MichaelChirico
Copy link
Owner Author

(In reply to Tomas Kalibera from comment #2)

There is some memory still reachable after R shuts down, which will be freed
by the operating system, so it does not cause any trouble. Looking at 

R -d "valgrind --leak-check=full --show-leak-kinds=all" -e "q()"

so, no cluster at all, the memory is mostly fragments of the R heap (which
will include heap unused by live R objects at that point), cache in
serialization, the symbol table, ICU data (statically cached collator),
cache of primitive methods for dispatch, connections for
stdin/stdout/stderr, registered routines in DLLs and external symbols,
dynamically linked objects using dlopen(), etc. Arranging for all of this
memory to be explicitly freed at shutdown of R would be a lot of work and
complicate the code substantially, it is not worth the effort and added
cognitive complexity as the memory will be freed by the OS right away.

R is not special in this, note it is common that there is "still reachable"
memory at program shutdown (try basic tools from binutils,...).

My problem was that R CMD check was failing while running some tests in which I was making use of a FORK cluster. After switching to a PSOCK cluster it worked fine. I've been able to reproduce the error running R code other than my package, e.g.

$ R --vanilla --debugger=valgrind --debugger-args="--track-origins=yes"
==17940== Memcheck, a memory error detector
==17940== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==17940== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==17940== Command: /usr/lib/R/bin/exec/R --vanilla
==17940== 
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x564EE77: __wcsnlen_avx2 (strlen-avx2.S:261)
==17940==    by 0x557CEC1: wcsrtombs (wcsrtombs.c:104)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x50A17BC: wcstombs (stdlib.h:154)
==17940==    by 0x50A17BC: tre_parse_bracket_items (tre-parse.c:336)
==17940==    by 0x50A17BC: tre_parse_bracket (tre-parse.c:453)
==17940==    by 0x50A17BC: tre_parse (tre-parse.c:1380)
==17940==    by 0x50991B8: tre_compile (tre-compile.c:1920)
==17940==    by 0x5096900: tre_regcompb (regcomp.c:150)
==17940==    by 0x4F97757: do_gsub (grep.c:1835)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F76E49: Rf_eval (eval.c:743)
==17940==  Uninitialised value was created by a stack allocation
==17940==    at 0x509FDED: tre_parse (tre-parse.c:943)
==17940== 
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x54E6408: internal_utf8_loop (loop.c:298)
==17940==    by 0x54E6408: __gconv_transform_internal_utf8 (skeleton.c:609)
==17940==    by 0x557CEF4: wcsrtombs (wcsrtombs.c:110)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x50A17BC: wcstombs (stdlib.h:154)
==17940==    by 0x50A17BC: tre_parse_bracket_items (tre-parse.c:336)
==17940==    by 0x50A17BC: tre_parse_bracket (tre-parse.c:453)
==17940==    by 0x50A17BC: tre_parse (tre-parse.c:1380)
==17940==    by 0x50991B8: tre_compile (tre-compile.c:1920)
==17940==    by 0x5096900: tre_regcompb (regcomp.c:150)
==17940==    by 0x4F97757: do_gsub (grep.c:1835)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F76E49: Rf_eval (eval.c:743)
==17940==  Uninitialised value was created by a stack allocation
==17940==    at 0x509FDED: tre_parse (tre-parse.c:943)
==17940== 
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x54E6411: internal_utf8_loop (loop.c:303)
==17940==    by 0x54E6411: __gconv_transform_internal_utf8 (skeleton.c:609)
==17940==    by 0x557CEF4: wcsrtombs (wcsrtombs.c:110)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x50A17BC: wcstombs (stdlib.h:154)
==17940==    by 0x50A17BC: tre_parse_bracket_items (tre-parse.c:336)
==17940==    by 0x50A17BC: tre_parse_bracket (tre-parse.c:453)
==17940==    by 0x50A17BC: tre_parse (tre-parse.c:1380)
==17940==    by 0x50991B8: tre_compile (tre-compile.c:1920)
==17940==    by 0x5096900: tre_regcompb (regcomp.c:150)
==17940==    by 0x4F97757: do_gsub (grep.c:1835)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F76E49: Rf_eval (eval.c:743)
==17940==  Uninitialised value was created by a stack allocation
==17940==    at 0x509FDED: tre_parse (tre-parse.c:943)
==17940== 
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x54E6458: internal_utf8_loop (loop.c:298)
==17940==    by 0x54E6458: __gconv_transform_internal_utf8 (skeleton.c:609)
==17940==    by 0x557CEF4: wcsrtombs (wcsrtombs.c:110)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x50A17BC: wcstombs (stdlib.h:154)
==17940==    by 0x50A17BC: tre_parse_bracket_items (tre-parse.c:336)
==17940==    by 0x50A17BC: tre_parse_bracket (tre-parse.c:453)
==17940==    by 0x50A17BC: tre_parse (tre-parse.c:1380)
==17940==    by 0x50991B8: tre_compile (tre-compile.c:1920)
==17940==    by 0x5096900: tre_regcompb (regcomp.c:150)
==17940==    by 0x4F97757: do_gsub (grep.c:1835)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F76E49: Rf_eval (eval.c:743)
==17940==  Uninitialised value was created by a stack allocation
==17940==    at 0x509FDED: tre_parse (tre-parse.c:943)
==17940== 

R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 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.

> library(parallel)
> sim_pi <- function(n, cl, size = 1000) {
+ 
+   pisimulator <- function(i) {
+     ans <- matrix(runif(size*2), ncol = 2)
+     ans[] <- ans ^ 2
+     mean(sqrt(rowSums(ans)) < 1) * 4
+   }
+ 
+   clusterExport(cl, c("pisimulator", "size"), envir = environment())
+ 
+   parSapply(cl, 1:n, pisimulator)
+ 
+ }
> 
> cl <- makePSOCKcluster(2)
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x564EE77: __wcsnlen_avx2 (strlen-avx2.S:261)
==17940==    by 0x557CEC1: wcsrtombs (wcsrtombs.c:104)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x4EF153B: wcstombs (stdlib.h:154)
==17940==    by 0x4EF153B: do_tolower (character.c:1032)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==  Uninitialised value was created by a heap allocation
==17940==    at 0x4C2FB0F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17940==    by 0x4FADD47: R_AllocStringBuffer (memory.c:4327)
==17940==    by 0x4EF14B8: do_tolower (character.c:1018)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940== 
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x54E6408: internal_utf8_loop (loop.c:298)
==17940==    by 0x54E6408: __gconv_transform_internal_utf8 (skeleton.c:609)
==17940==    by 0x557CEF4: wcsrtombs (wcsrtombs.c:110)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x4EF153B: wcstombs (stdlib.h:154)
==17940==    by 0x4EF153B: do_tolower (character.c:1032)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==  Uninitialised value was created by a heap allocation
==17940==    at 0x4C2FB0F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17940==    by 0x4FADD47: R_AllocStringBuffer (memory.c:4327)
==17940==    by 0x4EF14B8: do_tolower (character.c:1018)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940== 
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x54E6411: internal_utf8_loop (loop.c:303)
==17940==    by 0x54E6411: __gconv_transform_internal_utf8 (skeleton.c:609)
==17940==    by 0x557CEF4: wcsrtombs (wcsrtombs.c:110)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x4EF153B: wcstombs (stdlib.h:154)
==17940==    by 0x4EF153B: do_tolower (character.c:1032)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==  Uninitialised value was created by a heap allocation
==17940==    at 0x4C2FB0F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17940==    by 0x4FADD47: R_AllocStringBuffer (memory.c:4327)
==17940==    by 0x4EF14B8: do_tolower (character.c:1018)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940== 
==17940== Conditional jump or move depends on uninitialised value(s)
==17940==    at 0x54E6458: internal_utf8_loop (loop.c:298)
==17940==    by 0x54E6458: __gconv_transform_internal_utf8 (skeleton.c:609)
==17940==    by 0x557CEF4: wcsrtombs (wcsrtombs.c:110)
==17940==    by 0x5502B20: wcstombs (wcstombs.c:34)
==17940==    by 0x4EF153B: wcstombs (stdlib.h:154)
==17940==    by 0x4EF153B: do_tolower (character.c:1032)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==  Uninitialised value was created by a heap allocation
==17940==    at 0x4C2FB0F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17940==    by 0x4FADD47: R_AllocStringBuffer (memory.c:4327)
==17940==    by 0x4EF14B8: do_tolower (character.c:1018)
==17940==    by 0x4F69ED0: bcEval (eval.c:6765)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940==    by 0x4F76C7F: Rf_eval (eval.c:620)
==17940==    by 0x4F78ADE: R_execClosure (eval.c:1780)
==17940==    by 0x4F79822: Rf_applyClosure (eval.c:1706)
==17940==    by 0x4F6D821: bcEval (eval.c:6733)
==17940== 
> ans <- sim_pi(100, cl)

Closing PSOCK clusters is OK (no error)

> stopCluster(cl) # This runs fine
> 

The problem comes with FORK clusters

> cl <- makeForkCluster(2)
> ans <- sim_pi(100, cl)
> stopCluster(cl) # This reports errors
> ==17990== 
==17990== HEAP SUMMARY:
==17990==     in use at exit: 49,151,998 bytes in 11,803 blocks
==17990==   total heap usage: 24,427 allocs, 12,624 frees, 73,126,476 bytes
allocated
==17990== 
==17991== 
==17991== HEAP SUMMARY:
==17991==     in use at exit: 49,172,850 bytes in 11,810 blocks
==17991==   total heap usage: 24,439 allocs, 12,629 frees, 73,152,067 bytes
allocated
==17991== 
==17990== LEAK SUMMARY:
==17990==    definitely lost: 0 bytes in 0 blocks
==17990==    indirectly lost: 0 bytes in 0 blocks
==17990==      possibly lost: 0 bytes in 0 blocks
==17990==    still reachable: 49,151,998 bytes in 11,803 blocks
==17990==                       of which reachable via heuristic:
==17990==                         newarray           : 4,264 bytes in 1
blocks
==17990==         suppressed: 0 bytes in 0 blocks
==17990== Rerun with --leak-check=full to see details of leaked memory
==17990== 
==17990== For counts of detected and suppressed errors, rerun with: -v
==17990== ERROR SUMMARY: 708 errors from 8 contexts (suppressed: 0 from 0)
==17991== LEAK SUMMARY:
==17991==    definitely lost: 0 bytes in 0 blocks
==17991==    indirectly lost: 0 bytes in 0 blocks
==17991==      possibly lost: 0 bytes in 0 blocks
==17991==    still reachable: 49,172,850 bytes in 11,810 blocks
==17991==                       of which reachable via heuristic:
==17991==                         newarray           : 4,264 bytes in 1
blocks
==17991==         suppressed: 0 bytes in 0 blocks
==17991== Rerun with --leak-check=full to see details of leaked memory
==17991== 
==17991== For counts of detected and suppressed errors, rerun with: -v
==17991== ERROR SUMMARY: 708 errors from 8 contexts (suppressed: 0 from 0)

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
[9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods  
[8] base     

loaded via a namespace (and not attached):
[1] compiler_3.6.2
>

METADATA

  • Comment author - George Vega
  • Timestamp - 2020-01-15 19:27:14 UTC

@MichaelChirico
Copy link
Owner Author

(In reply to George Vega from comment #4)


My problem was that R CMD check was failing while running some tests in
which I was making use of a FORK cluster. After switching to a PSOCK cluster
it worked fine. 

Can you provide details (including error messages) of the R CMD check which failed?


METADATA

  • Comment author - Benjamin Tyner
  • Timestamp - 2020-01-15 22:57:46 UTC

@MichaelChirico
Copy link
Owner Author

In general, if your package is failing its tests and valgrind reports some issues, it does not mean that those issues are causes of the failure. The reports may also be false alarms, may be benign, or may be true problems but unrelated to the failure. The same is for R, in the reports you have included, I see the benign "still reachable" memory and then the uninitialized value in do_tolower, which seems to me to be a false alarm.


METADATA

  • Comment author - Tomas Kalibera
  • Timestamp - 2020-01-16 10:02:29 UTC

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

No branches or pull requests

1 participant