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

Fix valgrind issue #1094

Merged
merged 2 commits into from
Aug 1, 2023
Merged

Fix valgrind issue #1094

merged 2 commits into from
Aug 1, 2023

Conversation

hadley
Copy link
Member

@hadley hadley commented Jul 31, 2023

No description provided.

@hadley hadley requested a review from DavisVaughan July 31, 2023 17:41
break;
case LGLSXP:
to_friendly = "a logical";
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to keep things in sync, it looks like set_vector_value() does call cant_coerce() for RAWSXP too (but not for VECSXP, so no need to add that case)

@DavisVaughan
Copy link
Member

Dump of the valgrind issue, for posterity

==848144== Use of uninitialised value of size 8
==848144==    at 0x4D7FA9: SCALAR_LVAL (svn/R-devel/src/include/Rinlinedfuns.h:327)
==848144==    by 0x4D7FA9: GETSTACK_LOGICAL_PTR (svn/R-devel/src/main/eval.c:6569)
==848144==    by 0x4D7FA9: bcEval (svn/R-devel/src/main/eval.c:7682)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4E437D: bcEval (svn/R-devel/src/main/eval.c:7408)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4F425B: Rf_eval (svn/R-devel/src/main/eval.c:1146)
==848144==    by 0x1678356B: r_eval (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/./rlang/eval.h:7)
==848144==    by 0x1678356B: r_eval_with_xy (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/rlang/eval.c:18)
==848144==    by 0x16771863: rlang_obj_type_friendly_full (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/internal/cnd.c:206)
==848144==    by 0x18997A25: cant_coerce (packages/tests-vg/purrr/src/coerce.c:9)
==848144==  Uninitialised value was created by a client request
==848144==    at 0x532823: Rf_allocVector3 (svn/R-devel/src/main/memory.c:2673)
==848144==    by 0x189982F8: coerce_impl (packages/tests-vg/purrr/src/coerce.c:170)

Full output below:

==848144== Memcheck, a memory error detector
==848144== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==848144== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==848144== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R -f testthat.R --restore --save --no-readline --vanilla
==848144== 

R Under development (unstable) (2023-07-25 r84750) -- "Unsuffered Consequences"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

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.

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(testthat)
> library(purrr)

Attaching package: 'purrr'

The following object is masked from 'package:testthat':

    is_null

> 
> test_check("purrr")
==848144== Use of uninitialised value of size 8
==848144==    at 0x4D7FA9: SCALAR_LVAL (svn/R-devel/src/include/Rinlinedfuns.h:327)
==848144==    by 0x4D7FA9: GETSTACK_LOGICAL_PTR (svn/R-devel/src/main/eval.c:6569)
==848144==    by 0x4D7FA9: bcEval (svn/R-devel/src/main/eval.c:7682)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4E437D: bcEval (svn/R-devel/src/main/eval.c:7408)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4F425B: Rf_eval (svn/R-devel/src/main/eval.c:1146)
==848144==    by 0x1678356B: r_eval (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/./rlang/eval.h:7)
==848144==    by 0x1678356B: r_eval_with_xy (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/rlang/eval.c:18)
==848144==    by 0x16771863: rlang_obj_type_friendly_full (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/internal/cnd.c:206)
==848144==    by 0x18997A25: cant_coerce (packages/tests-vg/purrr/src/coerce.c:9)
==848144==  Uninitialised value was created by a client request
==848144==    at 0x532823: Rf_allocVector3 (svn/R-devel/src/main/memory.c:2673)
==848144==    by 0x189982F8: coerce_impl (packages/tests-vg/purrr/src/coerce.c:170)
==848144==    by 0x4A2469: R_doDotCall (svn/R-devel/src/main/dotcode.c:871)
==848144==    by 0x4E0FEC: bcEval (svn/R-devel/src/main/eval.c:7996)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4E437D: bcEval (svn/R-devel/src/main/eval.c:7408)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4F425B: Rf_eval (svn/R-devel/src/main/eval.c:1146)
==848144== 
==848144== Conditional jump or move depends on uninitialised value(s)
==848144==    at 0x46EC8B: do_isinfinite (svn/R-devel/src/main/coerce.c:2627)
==848144==    by 0x4DB7EE: bcEval (svn/R-devel/src/main/eval.c:7440)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4F425B: Rf_eval (svn/R-devel/src/main/eval.c:1146)
==848144==    by 0x1678356B: r_eval (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/./rlang/eval.h:7)
==848144==    by 0x1678356B: r_eval_with_xy (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/rlang/eval.c:18)
==848144==    by 0x16771863: rlang_obj_type_friendly_full (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/internal/cnd.c:206)
==848144==    by 0x18997A25: cant_coerce (packages/tests-vg/purrr/src/coerce.c:9)
==848144==    by 0x189980BE: set_vector_value (packages/tests-vg/purrr/src/coerce.c:124)
==848144==    by 0x18998321: coerce_impl (packages/tests-vg/purrr/src/coerce.c:173)
==848144==    by 0x4A2469: R_doDotCall (svn/R-devel/src/main/dotcode.c:871)
==848144==  Uninitialised value was created by a client request
==848144==    at 0x532823: Rf_allocVector3 (svn/R-devel/src/main/memory.c:2673)
==848144==    by 0x189982F8: coerce_impl (packages/tests-vg/purrr/src/coerce.c:170)
==848144==    by 0x4A2469: R_doDotCall (svn/R-devel/src/main/dotcode.c:871)
==848144==    by 0x4E0FEC: bcEval (svn/R-devel/src/main/eval.c:7996)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4E437D: bcEval (svn/R-devel/src/main/eval.c:7408)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4F425B: Rf_eval (svn/R-devel/src/main/eval.c:1146)
==848144== 
==848144== Conditional jump or move depends on uninitialised value(s)
==848144==    at 0x4D97D1: bcEval (svn/R-devel/src/main/eval.c:6902)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4F425B: Rf_eval (svn/R-devel/src/main/eval.c:1146)
==848144==    by 0x1678356B: r_eval (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/./rlang/eval.h:7)
==848144==    by 0x1678356B: r_eval_with_xy (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/rlang/eval.c:18)
==848144==    by 0x16771863: rlang_obj_type_friendly_full (/tmp/RtmpSHso01/R.INSTALL1e939055c15d56/rlang/src/internal/cnd.c:206)
==848144==    by 0x18997A25: cant_coerce (packages/tests-vg/purrr/src/coerce.c:9)
==848144==    by 0x189980BE: set_vector_value (packages/tests-vg/purrr/src/coerce.c:124)
==848144==    by 0x18998321: coerce_impl (packages/tests-vg/purrr/src/coerce.c:173)
==848144==    by 0x4A2469: R_doDotCall (svn/R-devel/src/main/dotcode.c:871)
==848144==    by 0x4E0FEC: bcEval (svn/R-devel/src/main/eval.c:7996)
==848144==  Uninitialised value was created by a client request
==848144==    at 0x532823: Rf_allocVector3 (svn/R-devel/src/main/memory.c:2673)
==848144==    by 0x189982F8: coerce_impl (packages/tests-vg/purrr/src/coerce.c:170)
==848144==    by 0x4A2469: R_doDotCall (svn/R-devel/src/main/dotcode.c:871)
==848144==    by 0x4E0FEC: bcEval (svn/R-devel/src/main/eval.c:7996)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4E437D: bcEval (svn/R-devel/src/main/eval.c:7408)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4F425B: Rf_eval (svn/R-devel/src/main/eval.c:1146)
==848144== 
[ FAIL 0 | WARN 0 | SKIP 112 | PASS 722 ]

══ Skipped tests (112) ═════════════════════════════════════════════════════════
• On CRAN (112): 'test-adverb-auto-browse.R:2:3', 'test-adverb-compose.R:50:3',
  'test-adverb-insistently.R:3:3', 'test-adverb-insistently.R:8:3',
  'test-adverb-partial.R:66:3', 'test-adverb-partial.R:147:3',
  'test-adverb-partial.R:176:3', 'test-adverb-slowly.R:2:3',
  'test-arrays.R:17:3', 'test-coerce.R:37:3', 'test-coerce.R:52:3',
  'test-conditions.R:2:3', 'test-conditions.R:8:3', 'test-conditions.R:14:3',
  'test-conditions.R:18:3', 'test-deprec-along.R:2:3',
  'test-deprec-cross.R:22:3', 'test-deprec-invoke.R:2:3',
  'test-deprec-lift.R:45:3', 'test-deprec-map.R:2:3',
  'test-deprec-prepend.R:2:3', 'test-deprec-rerun.R:2:3',
  'test-deprec-splice.R:20:3', 'test-deprec-utils.R:2:3',
  'test-deprec-when.R:2:3', 'test-detect.R:25:3', 'test-detect.R:34:3',
  'test-head-tail.R:17:3', 'test-keep.R:12:3', 'test-list-combine.R:5:3',
  'test-list-combine.R:11:3', 'test-list-combine.R:27:3',
  'test-list-combine.R:34:3', 'test-list-combine.R:50:3',
  'test-list-combine.R:58:3', 'test-list-combine.R:84:3',
  'test-list-combine.R:99:3', 'test-list-flatten.R:23:3',
  'test-list-modify.R:90:3', 'test-list-modify.R:128:3',
  'test-list-modify.R:135:3', 'test-list-simplify.R:16:3',
  'test-list-simplify.R:22:3', 'test-list-simplify.R:40:3',
  'test-list-simplify.R:45:3', 'test-list-transpose.R:64:3',
  'test-list-transpose.R:82:3', 'test-list-transpose.R:98:3',
  'test-list-transpose.R:111:3', 'test-list-transpose.R:124:3',
  'test-list-transpose.R:128:3', 'test-lmap.R:53:3', 'test-map-depth.R:11:3',
  'test-map-depth.R:52:3', 'test-map-depth.R:92:3', 'test-map-if-at.R:28:3',
  'test-map-raw.R:2:3', 'test-map.R:12:3', 'test-map.R:34:3',
  'test-map.R:51:3', 'test-map.R:130:3', 'test-map.R:147:3',
  'test-map2.R:27:3', 'test-map2.R:41:3', 'test-map2.R:52:3',
  'test-modify-tree.R:39:3', 'test-modify.R:18:3', 'test-modify.R:28:3',
  'test-modify.R:54:3', 'test-modify.R:137:3', 'test-modify.R:144:3',
  'test-modify.R:150:3', 'test-pluck-assign.R:50:3', 'test-pluck-depth.R:25:3',
  'test-pluck.R:3:3', 'test-pluck.R:27:3', 'test-pluck.R:35:3',
  'test-pluck.R:50:3', 'test-pluck.R:65:3', 'test-pluck.R:81:3',
  'test-pluck.R:90:3', 'test-pluck.R:109:3', 'test-pluck.R:114:3',
  'test-pluck.R:123:3', 'test-pluck.R:176:3', 'test-pluck.R:201:3',
  'test-pluck.R:206:3', 'test-pluck.R:220:3', 'test-pluck.R:226:3',
  'test-pmap.R:28:3', 'test-pmap.R:46:3', 'test-pmap.R:57:3',
  'test-rate.R:20:3', 'test-rate.R:48:3', 'test-rate.R:69:3',
  'test-rate.R:75:3', 'test-reduce.R:2:3', 'test-reduce.R:120:3',
  'test-reduce.R:134:3', 'test-reduce.R:138:3', 'test-reduce.R:193:3',
  'test-superseded-flatten.R:4:3', 'test-superseded-flatten.R:11:3',
  'test-superseded-flatten.R:62:3', 'test-superseded-transpose.R:2:3',
  'test-superseded-transpose.R:6:3', 'test-superseded-transpose.R:53:3',
  'test-utils.R:13:3', 'test-utils.R:34:3', 'test-utils.R:38:3',
  'test-utils.R:56:3', 'test-utils.R:110:3'

[ FAIL 0 | WARN 0 | SKIP 112 | PASS 722 ]
> 
> proc.time()
    user   system  elapsed 
2117.355    9.192 2137.025 
==848144== 
==848144== HEAP SUMMARY:
==848144==     in use at exit: 114,864,979 bytes in 25,326 blocks
==848144==   total heap usage: 1,638,165 allocs, 1,612,839 frees, 2,040,166,082 bytes allocated
==848144== 
==848144== 352 bytes in 1 blocks are possibly lost in loss record 148 of 2,558
==848144==    at 0x4845464: calloc (/builddir/build/BUILD/valgrind-3.18.1/coregrind/m_replacemalloc/vg_replace_malloc.c:1328)
==848144==    by 0x401364B: UnknownInlinedFun (/usr/src/debug/glibc-2.33-21.fc34.x86_64/elf/../include/rtld-malloc.h:44)
==848144==    by 0x401364B: allocate_dtv (/usr/src/debug/glibc-2.33-21.fc34.x86_64/elf/../elf/dl-tls.c:366)
==848144==    by 0x401364B: _dl_allocate_tls (/usr/src/debug/glibc-2.33-21.fc34.x86_64/elf/../elf/dl-tls.c:612)
==848144==    by 0x53C8008: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.33.so)
==848144==    by 0x16BAE5CE: cli__start_thread (/tmp/RtmpnsoHc0/R.INSTALL1ca6fe4392ae8f/cli/src/thread.c:54)
==848144==    by 0x16BAE617: clic_start_thread (/tmp/RtmpnsoHc0/R.INSTALL1ca6fe4392ae8f/cli/src/thread.c:78)
==848144==    by 0x4A244D: R_doDotCall (svn/R-devel/src/main/dotcode.c:874)
==848144==    by 0x4E0FEC: bcEval (svn/R-devel/src/main/eval.c:7996)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144==    by 0x4F5F8E: R_execClosure (svn/R-devel/src/main/eval.c:2193)
==848144==    by 0x4F6CC2: Rf_applyClosure (svn/R-devel/src/main/eval.c:2119)
==848144==    by 0x4E437D: bcEval (svn/R-devel/src/main/eval.c:7408)
==848144==    by 0x4F414F: Rf_eval (svn/R-devel/src/main/eval.c:1019)
==848144== 
==848144== LEAK SUMMARY:
==848144==    definitely lost: 0 bytes in 0 blocks
==848144==    indirectly lost: 0 bytes in 0 blocks
==848144==      possibly lost: 352 bytes in 1 blocks
==848144==    still reachable: 114,864,627 bytes in 25,325 blocks
==848144==         suppressed: 0 bytes in 0 blocks
==848144== Reachable blocks (those to which a pointer was found) are not shown.
==848144== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==848144== 
==848144== For lists of detected and suppressed errors, rerun with: -s
==848144== ERROR SUMMARY: 11 errors from 4 contexts (suppressed: 0 from 0)

@hadley hadley merged commit 110b22f into main Aug 1, 2023
11 checks passed
@hadley hadley deleted the fix-valgrind-issue branch August 1, 2023 18:56
@hadley hadley mentioned this pull request Jul 31, 2023
15 tasks
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

Successfully merging this pull request may close these issues.

2 participants