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 ASAN issue in h5dump error path #1051

Merged
merged 2 commits into from
Oct 3, 2021
Merged

Fix ASAN issue in h5dump error path #1051

merged 2 commits into from
Oct 3, 2021

Conversation

byrnHDF
Copy link
Contributor

@byrnHDF byrnHDF commented Sep 29, 2021

Dynamic Analysis indicated an error when there was an error in the table add function, created tables need to be freed in the error block because otherwise there is no indication they were created. The count is only updated after there is an addition to the tables.

==1031476==ERROR: LeakSanitizer: detected memory leaks

Direct leak Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x498bdd in malloc (/home/hdf-winadmin/autotest/hdf5trunk-StdClang-code-ubuntu2010/build/ctest/clang/Address/bin/h5dump-shared+0x498bdd)
#1 0x7f2dad24b2c5 in init_objs (/home/hdf-winadmin/autotest/hdf5trunk-StdClang-code-ubuntu2010/build/ctest/clang/Address/bin/libhdf5_tools.so.1000+0x912c5)
#2 0x4c897f in table_list_add (/home/hdf-winadmin/autotest/hdf5trunk-StdClang-code-ubuntu2010/build/ctest/clang/Address/bin/h5dump-shared+0x4c897f)
#3 0x4ca790 in main (/home/hdf-winadmin/autotest/hdf5trunk-StdClang-code-ubuntu2010/build/ctest/clang/Address/bin/h5dump-shared+0x4ca790)
#4 0x7f2dac025cb1 in __libc_start_main csu/../csu/libc-start.c:314:16

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Sep 29, 2021

h5dump Tests
H5DUMP-tCVE_2018_11206_fill_old
H5DUMP-tCVE_2018_11206_fill_new

@byrnHDF byrnHDF self-assigned this Sep 29, 2021
This was referenced Sep 30, 2021
Copy link
Contributor

@bmribler bmribler left a comment

Choose a reason for hiding this comment

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

I left a comment

/* table_list.nused will be zero and the added containers needs to be cleaned up */
HDfree(table_list.tables[0].group_table);
HDfree(table_list.tables[0].dset_table);
HDfree(table_list.tables[0].type_table);
goto done;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not very familiar with the code, but, generally, I think freeing should be done in done:, also, should table_list_free() be used somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally, yes, but these are pointers not captured anywhere else until later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume that since the sanitizer reported an issue, table_list_free() in done wasn't freeing these group, dset, and type tables belonging to table_list.tables[0]? Should table_list_free() in done (line 1614) have freed them? Is there a need to check that they exist before freeing them here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. If these lines stay there, the pointers need to be checked before freeing.

@lrknox lrknox merged commit eca8d5b into HDFGroup:develop Oct 3, 2021
lrknox pushed a commit that referenced this pull request Oct 4, 2021
* Merge ASAN fixes

Fix ASAN issue in h5dump error path #1051
ASAN fix for test_ld - free sub-allocation of fields #10

* Merge Rework error allocation free.
lrknox added a commit that referenced this pull request Oct 4, 2021
…1070)

* Update so numbers for libhdf5_java.so due to functions added to Java
API.
Remove -avoid-version flag that supresses so version numbers from java/src/jni/Makefile.am.

* 1.10 Merge ASAN fixes (#1060)

* Merge ASAN fixes

Fix ASAN issue in h5dump error path #1051
ASAN fix for test_ld - free sub-allocation of fields #10

* Merge Rework error allocation free.

Co-authored-by: Allen Byrne <[email protected]>
lrknox pushed a commit that referenced this pull request Oct 6, 2021
* Merge ASAN fixes

Fix ASAN issue in h5dump error path #1051
ASAN fix for test_ld - free sub-allocation of fields #1052

* Merge Rework error allocation free.
lrknox pushed a commit that referenced this pull request Oct 8, 2021
* Merge Fix ASAN issue in h5dump error path #1051

* Merge Rework error allocation free.
@byrnHDF byrnHDF deleted the develop-dyan-table-list branch November 1, 2021 13:05
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.

3 participants