-
Notifications
You must be signed in to change notification settings - Fork 71
Fix Coverity issues in acl_profiler_test.cpp
#267
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pcolberg
suggested changes
Feb 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @IlanTruanovsky!
There were two issues: - A file deletion operation's return value was not being checked. I ignored the return value. - An array in a struct was not being initialized, even though it is updated by the HAL only. Fixes: ``` test/acl_profiler_test.cpp:614:7: Type: Unchecked return value from library (CHECKED_RETURN) test/acl_profiler_test.cpp:613:5: Unchecked call to function 1. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:614:7: 2. check_return: Calling "remove("profile.mon")" without checking return value. This library function may fail and return an error code. test/acl_profiler_test.cpp:436:3: Type: Uninitialized scalar variable (UNINIT) test/acl_profiler_test.cpp:431:3: 1. var_decl: Declaring variable "op". test/acl_profiler_test.cpp:435:3: 2. path: Condition "!acl_event_is_valid(op.info.event)", taking true branch. test/acl_profiler_test.cpp:435:3: 3. path: Condition "!Utest::getCurrent()->assertTrue(!acl_event_is_valid(op.info.event), "!acl_event_is_valid(op.info.event)", "../../test/acl_profiler_test.cpp", 435)", taking false branch. test/acl_profiler_test.cpp:436:3: 4. uninit_use_in_call: Using uninitialized element of array "op.timestamp" when calling "acl_process_profiler_scan_chain". src/acl_profiler.cpp:734:3: 4.1. path: Condition "!profile_enable", taking false branch. src/acl_profiler.cpp:747:3: 4.2. path: Condition "!acl_is_inside_sig()", taking true branch. src/acl_profiler.cpp:758:3: 4.3. path: Condition "!acl_is_inside_sig()", taking true branch. src/acl_profiler.cpp:761:5: 4.4. path: Condition "!acl_event_is_valid(event)", taking false branch. src/acl_profiler.cpp:766:5: 4.5. path: Condition "!acl_command_queue_is_valid(event->command_queue)", taking false branch. src/acl_profiler.cpp:771:5: 4.6. path: Condition "acl_event_is_done(event)", taking false branch. src/acl_profiler.cpp:781:3: 4.7. path: Condition "!device_id", taking false branch. src/acl_profiler.cpp:789:3: 4.8. path: Condition "op_type != ACL_DEVICE_OP_KERNEL", taking true branch. src/acl_profiler.cpp:789:3: 4.9. path: Condition "profile_timer_on != 1", taking false branch. src/acl_profiler.cpp:794:3: 4.10. path: Condition "op_type == ACL_DEVICE_OP_KERNEL", taking false branch. src/acl_profiler.cpp:823:10: 4.11. path: Condition "profile_timer_on != 1", taking false branch. src/acl_profiler.cpp:827:10: 4.12. path: Condition "op_type == ACL_DEVICE_OP_MEM_TRANSFER_COPY", taking true branch. src/acl_profiler.cpp:829:3: 4.13. path: Falling through to end of if statement. src/acl_profiler.cpp:849:3: 4.14. read_value: Reading value "op->timestamp[0]". src/acl_profiler.cpp:850:3: 4.15. path: Condition "end_time == 0", taking true branch. src/acl_profiler.cpp:864:3: 4.16. path: Condition "op->timestamp[0] != 0", taking true branch. test/acl_profiler_test.cpp:442:3: Type: Uninitialized scalar variable (UNINIT) test/acl_profiler_test.cpp:431:3: 1. var_decl: Declaring variable "op". test/acl_profiler_test.cpp:435:3: 2. path: Condition "!acl_event_is_valid(op.info.event)", taking true branch. test/acl_profiler_test.cpp:435:3: 3. path: Condition "!Utest::getCurrent()->assertTrue(!acl_event_is_valid(op.info.event), "!acl_event_is_valid(op.info.event)", "../../test/acl_profiler_test.cpp", 435)", taking false branch. test/acl_profiler_test.cpp:436:3: 4. path: Condition "!acl_process_profiler_scan_chain(&op)", taking true branch. test/acl_profiler_test.cpp:436:3: 5. path: Condition "!Utest::getCurrent()->assertTrue(!acl_process_profiler_scan_chain(&op), "!acl_process_profiler_scan_chain(&op)", "../../test/acl_profiler_test.cpp", 436)", taking false branch. test/acl_profiler_test.cpp:441:3: 6. path: Condition "!acl_event_is_valid(op.info.event)", taking true branch. test/acl_profiler_test.cpp:441:3: 7. path: Condition "!Utest::getCurrent()->assertTrue(!acl_event_is_valid(op.info.event), "!acl_event_is_valid(op.info.event)", "../../test/acl_profiler_test.cpp", 441)", taking false branch. test/acl_profiler_test.cpp:442:3: 8. uninit_use_in_call: Using uninitialized element of array "op.timestamp" when calling "acl_process_profiler_scan_chain". src/acl_profiler.cpp:734:3: 8.1. path: Condition "!profile_enable", taking false branch. src/acl_profiler.cpp:747:3: 8.2. path: Condition "!acl_is_inside_sig()", taking true branch. src/acl_profiler.cpp:758:3: 8.3. path: Condition "!acl_is_inside_sig()", taking true branch. src/acl_profiler.cpp:761:5: 8.4. path: Condition "!acl_event_is_valid(event)", taking false branch. src/acl_profiler.cpp:766:5: 8.5. path: Condition "!acl_command_queue_is_valid(event->command_queue)", taking false branch. src/acl_profiler.cpp:771:5: 8.6. path: Condition "acl_event_is_done(event)", taking false branch. src/acl_profiler.cpp:781:3: 8.7. path: Condition "!device_id", taking false branch. src/acl_profiler.cpp:789:3: 8.8. path: Condition "op_type != ACL_DEVICE_OP_KERNEL", taking true branch. src/acl_profiler.cpp:789:3: 8.9. path: Condition "profile_timer_on != 1", taking false branch. src/acl_profiler.cpp:794:3: 8.10. path: Condition "op_type == ACL_DEVICE_OP_KERNEL", taking false branch. src/acl_profiler.cpp:823:10: 8.11. path: Condition "profile_timer_on != 1", taking false branch. src/acl_profiler.cpp:827:10: 8.12. path: Condition "op_type == ACL_DEVICE_OP_MEM_TRANSFER_COPY", taking true branch. src/acl_profiler.cpp:829:3: 8.13. path: Falling through to end of if statement. src/acl_profiler.cpp:849:3: 8.14. read_value: Reading value "op->timestamp[0]". src/acl_profiler.cpp:850:3: 8.15. path: Condition "end_time == 0", taking true branch. src/acl_profiler.cpp:864:3: 8.16. path: Condition "op->timestamp[0] != 0", taking true branch. ```
6a5f1e6
to
d2337de
Compare
GitHub is having issues with their container infrastructure again:
|
pcolberg
approved these changes
Feb 3, 2023
IlanTruanovsky
added a commit
to IlanTruanovsky/fpga-runtime-for-opencl
that referenced
this pull request
Feb 6, 2023
Coverity picked up a `RESOURCE_LEAK` error that was not fixed in intel#267 Fixes: ``` test/acl_profiler_test.cpp:812:3: Type: Resource leak (RESOURCE_LEAK) test/acl_profiler_test.cpp:756:3: 1. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:758:5: 2. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:758:5: 3. path: Falling through to end of if statement. test/acl_profiler_test.cpp:763:5: 4. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:763:5: 5. path: Falling through to end of if statement. test/acl_profiler_test.cpp:765:5: 6. path: Condition "0 != clSetKernelArg(kernel, 0, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:765:5: 7. path: Falling through to end of if statement. test/acl_profiler_test.cpp:767:5: 8. path: Condition "0 != clSetKernelArg(kernel, 1, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:767:5: 9. path: Falling through to end of if statement. test/acl_profiler_test.cpp:769:5: 10. path: Condition "0 != clSetKernelArg(kernel, 2, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:769:5: 11. path: Falling through to end of if statement. test/acl_profiler_test.cpp:777:5: 12. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:777:5: 13. path: Falling through to end of if statement. test/acl_profiler_test.cpp:784:3: 14. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:786:5: 15. path: Condition "active_op", taking true branch. test/acl_profiler_test.cpp:786:5: 16. path: Condition "!Utest::getCurrent()->assertTrue(active_op, "active_op", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 786)", taking true branch. test/acl_profiler_test.cpp:787:5: 17. path: Condition "ACL_DEVICE_OP_KERNEL != active_op->info.type", taking true branch. test/acl_profiler_test.cpp:787:5: 18. path: Falling through to end of if statement. test/acl_profiler_test.cpp:796:3: 19. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:797:5: 20. alloc_fn: Storage is returned from allocation function "fopen". test/acl_profiler_test.cpp:797:5: 21. var_assign: Assigning: "fp" = storage returned from "fopen("profile.mon", "r")". test/acl_profiler_test.cpp:798:5: 22. path: Condition "fp == NULL", taking false branch. test/acl_profiler_test.cpp:798:5: 23. path: Condition "!Utest::getCurrent()->assertTrue(fp == NULL, "fp == NULL", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 798)", taking true branch. test/acl_profiler_test.cpp:805:5: 24. path: Condition "acl_process_profiler_scan_chain(event->current_device_op)", taking true branch. test/acl_profiler_test.cpp:805:5: 25. path: Condition "!Utest::getCurrent()->assertTrue(acl_process_profiler_scan_chain(event->current_device_op), "acl_process_profiler_scan_chain(event->current_device_op)", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 806)", taking true branch. test/acl_profiler_test.cpp:807:5: 26. path: Condition "acl_process_autorun_profiler_scan_chain(0, 0)", taking true branch. test/acl_profiler_test.cpp:807:5: 27. path: Condition "!Utest::getCurrent()->assertTrue(acl_process_autorun_profiler_scan_chain(0, 0), "acl_process_autorun_profiler_scan_chain(0, 0)", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 807)", taking true branch. test/acl_profiler_test.cpp:812:3: 28. leaked_storage: Variable "fp" going out of scope leaks the storage it points to. ```
pcolberg
pushed a commit
to IlanTruanovsky/fpga-runtime-for-opencl
that referenced
this pull request
Feb 8, 2023
Coverity picked up a `RESOURCE_LEAK` error that was not fixed in intel#267 Fixes: ``` test/acl_profiler_test.cpp:812:3: Type: Resource leak (RESOURCE_LEAK) test/acl_profiler_test.cpp:756:3: 1. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:758:5: 2. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:758:5: 3. path: Falling through to end of if statement. test/acl_profiler_test.cpp:763:5: 4. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:763:5: 5. path: Falling through to end of if statement. test/acl_profiler_test.cpp:765:5: 6. path: Condition "0 != clSetKernelArg(kernel, 0, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:765:5: 7. path: Falling through to end of if statement. test/acl_profiler_test.cpp:767:5: 8. path: Condition "0 != clSetKernelArg(kernel, 1, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:767:5: 9. path: Falling through to end of if statement. test/acl_profiler_test.cpp:769:5: 10. path: Condition "0 != clSetKernelArg(kernel, 2, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:769:5: 11. path: Falling through to end of if statement. test/acl_profiler_test.cpp:777:5: 12. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:777:5: 13. path: Falling through to end of if statement. test/acl_profiler_test.cpp:784:3: 14. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:786:5: 15. path: Condition "active_op", taking true branch. test/acl_profiler_test.cpp:786:5: 16. path: Condition "!Utest::getCurrent()->assertTrue(active_op, "active_op", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 786)", taking true branch. test/acl_profiler_test.cpp:787:5: 17. path: Condition "ACL_DEVICE_OP_KERNEL != active_op->info.type", taking true branch. test/acl_profiler_test.cpp:787:5: 18. path: Falling through to end of if statement. test/acl_profiler_test.cpp:796:3: 19. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:797:5: 20. alloc_fn: Storage is returned from allocation function "fopen". test/acl_profiler_test.cpp:797:5: 21. var_assign: Assigning: "fp" = storage returned from "fopen("profile.mon", "r")". test/acl_profiler_test.cpp:798:5: 22. path: Condition "fp == NULL", taking false branch. test/acl_profiler_test.cpp:798:5: 23. path: Condition "!Utest::getCurrent()->assertTrue(fp == NULL, "fp == NULL", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 798)", taking true branch. test/acl_profiler_test.cpp:805:5: 24. path: Condition "acl_process_profiler_scan_chain(event->current_device_op)", taking true branch. test/acl_profiler_test.cpp:805:5: 25. path: Condition "!Utest::getCurrent()->assertTrue(acl_process_profiler_scan_chain(event->current_device_op), "acl_process_profiler_scan_chain(event->current_device_op)", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 806)", taking true branch. test/acl_profiler_test.cpp:807:5: 26. path: Condition "acl_process_autorun_profiler_scan_chain(0, 0)", taking true branch. test/acl_profiler_test.cpp:807:5: 27. path: Condition "!Utest::getCurrent()->assertTrue(acl_process_autorun_profiler_scan_chain(0, 0), "acl_process_autorun_profiler_scan_chain(0, 0)", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 807)", taking true branch. test/acl_profiler_test.cpp:812:3: 28. leaked_storage: Variable "fp" going out of scope leaks the storage it points to. ```
pcolberg
pushed a commit
that referenced
this pull request
Feb 8, 2023
Coverity picked up a `RESOURCE_LEAK` error that was not fixed in #267 Fixes: ``` test/acl_profiler_test.cpp:812:3: Type: Resource leak (RESOURCE_LEAK) test/acl_profiler_test.cpp:756:3: 1. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:758:5: 2. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:758:5: 3. path: Falling through to end of if statement. test/acl_profiler_test.cpp:763:5: 4. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:763:5: 5. path: Falling through to end of if statement. test/acl_profiler_test.cpp:765:5: 6. path: Condition "0 != clSetKernelArg(kernel, 0, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:765:5: 7. path: Falling through to end of if statement. test/acl_profiler_test.cpp:767:5: 8. path: Condition "0 != clSetKernelArg(kernel, 1, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:767:5: 9. path: Falling through to end of if statement. test/acl_profiler_test.cpp:769:5: 10. path: Condition "0 != clSetKernelArg(kernel, 2, 8UL /* sizeof (cl_mem) */, &src_mem)", taking true branch. test/acl_profiler_test.cpp:769:5: 11. path: Falling through to end of if statement. test/acl_profiler_test.cpp:777:5: 12. path: Condition "0 != status", taking true branch. test/acl_profiler_test.cpp:777:5: 13. path: Falling through to end of if statement. test/acl_profiler_test.cpp:784:3: 14. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:786:5: 15. path: Condition "active_op", taking true branch. test/acl_profiler_test.cpp:786:5: 16. path: Condition "!Utest::getCurrent()->assertTrue(active_op, "active_op", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 786)", taking true branch. test/acl_profiler_test.cpp:787:5: 17. path: Condition "ACL_DEVICE_OP_KERNEL != active_op->info.type", taking true branch. test/acl_profiler_test.cpp:787:5: 18. path: Falling through to end of if statement. test/acl_profiler_test.cpp:796:3: 19. path: Condition "MtUtest::threadNum() == 0", taking true branch. test/acl_profiler_test.cpp:797:5: 20. alloc_fn: Storage is returned from allocation function "fopen". test/acl_profiler_test.cpp:797:5: 21. var_assign: Assigning: "fp" = storage returned from "fopen("profile.mon", "r")". test/acl_profiler_test.cpp:798:5: 22. path: Condition "fp == NULL", taking false branch. test/acl_profiler_test.cpp:798:5: 23. path: Condition "!Utest::getCurrent()->assertTrue(fp == NULL, "fp == NULL", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 798)", taking true branch. test/acl_profiler_test.cpp:805:5: 24. path: Condition "acl_process_profiler_scan_chain(event->current_device_op)", taking true branch. test/acl_profiler_test.cpp:805:5: 25. path: Condition "!Utest::getCurrent()->assertTrue(acl_process_profiler_scan_chain(event->current_device_op), "acl_process_profiler_scan_chain(event->current_device_op)", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 806)", taking true branch. test/acl_profiler_test.cpp:807:5: 26. path: Condition "acl_process_autorun_profiler_scan_chain(0, 0)", taking true branch. test/acl_profiler_test.cpp:807:5: 27. path: Condition "!Utest::getCurrent()->assertTrue(acl_process_autorun_profiler_scan_chain(0, 0), "acl_process_autorun_profiler_scan_chain(0, 0)", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_profiler_test.cpp", 807)", taking true branch. test/acl_profiler_test.cpp:812:3: 28. leaked_storage: Variable "fp" going out of scope leaks the storage it points to. ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There were two issues:
Fixes: