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 an issue with use of uninitialized memory in trefer_deprec.c test #3422

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/trefer_deprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high)
CHECK(ret, FAIL, "H5Dread");

/* Try to read an unaddressed dataset */
memset(&undef_reg, 0, sizeof(undef_reg));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The point of this test is to make sure that trying to use an uninitialized reference fails, but it also ends up reading from completely uninitialized memory. When run with valgrind, the memory often gets initialized such that

=4676== Conditional jump or move depends on uninitialised value(s)
==4676==    at 0x4B3D7A1: H5F_addr_decode_len (H5Fint.c:2901)
==4676==    by 0x4B3D815: H5F_addr_decode (H5Fint.c:2947)
==4676==    by 0x4CF1890: H5R__decode_heap (H5Rint.c:1384)
==4676==    by 0x4CF1E13: H5R__decode_token_region_compat (H5Rint.c:1493)
==4676==    by 0x4CEB5D7: H5R__decode_token_compat (H5Rdeprec.c:147)
==4676==    by 0x4CED3AE: H5Rdereference2 (H5Rdeprec.c:596)
==4676==    by 0x55126F: test_reference_region (trefer_deprec.c:775)
==4676==    by 0x559607: test_reference_deprec (trefer_deprec.c:1832)
==4676==    by 0x485B88C: PerformTests (testframe.c:311)
==4676==    by 0x40C30B: main (testhdf5.c:76)
==4676== 

testhdf5: .../src/H5HGcache.c:190: H5HG__cache_heap_get_final_load_size: Assertion `image_len == H5HG_MINSIZE' failed.

shows up. Initializing the memory to all 0 accomplishes the same thing and doesn't read random memory.

dset2 = H5Rdereference2(dset1, dapl_id, H5R_DATASET_REGION, undef_reg);
VERIFY(dset2, FAIL, "H5Rdereference2 haddr_undef");

Expand Down