-
Notifications
You must be signed in to change notification settings - Fork 70
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 Coverity OVERRUN
error for acl_hal_test.cpp
#273
Conversation
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. Maybe I am missing something, but it looks like the Coverity issue is still present?
2023-02-06T15:15:35.8843951Z test/acl_hal_test.cpp:362:3:
2023-02-06T15:15:35.8844285Z Type: Out-of-bounds access (OVERRUN)
Hmm I thought I checked. Let me test some more. |
This is really strange. It does not show up when I run a local Coverity scan. I doubt the workflow is checking out the wrong code though? Not sure what is happening. |
2302397
to
ec429e9
Compare
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. Please also update the commit message to reflect the change.
A function was being passed in the wrong length of a pointer. Fixes: ``` test/acl_hal_test.cpp:362:3: Type: Out-of-bounds access (OVERRUN) test/acl_hal_test.cpp:303:3: 1. path: Condition "acl_set_hal(&simple_hal)", taking false branch. test/acl_hal_test.cpp:303:3: 2. path: Condition "!Utest::getCurrent()->assertTrue(acl_set_hal(&simple_hal), "acl_set_hal(&simple_hal)", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 303)", taking true branch. test/acl_hal_test.cpp:308:3: 3. path: Condition "acl_debug_env", taking true branch. test/acl_hal_test.cpp:308:3: 4. path: Condition "!Utest::getCurrent()->assertTrue(acl_debug_env, "acl_debug_env", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 308)", taking true branch. test/acl_hal_test.cpp:311:3: 5. path: Condition "0 != debug_mode", taking false branch. test/acl_hal_test.cpp:313:3: 6. path: Condition "0 != acl_print_debug_msg("some text")", taking true branch. test/acl_hal_test.cpp:313:3: 7. path: Falling through to end of if statement. test/acl_hal_test.cpp:314:3: 8. path: Condition "0 != acl_print_debug_msg("")", taking true branch. test/acl_hal_test.cpp:314:3: 9. path: Falling through to end of if statement. test/acl_hal_test.cpp:319:3: 10. path: Condition "acl_debug_env", taking true branch. test/acl_hal_test.cpp:319:3: 11. path: Condition "!Utest::getCurrent()->assertTrue(acl_debug_env, "acl_debug_env", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 319)", taking true branch. test/acl_hal_test.cpp:321:3: 12. path: Condition "4 != debug_mode", taking true branch. test/acl_hal_test.cpp:321:3: 13. path: Falling through to end of if statement. test/acl_hal_test.cpp:324:3: 14. path: Condition "acl_debug_env", taking true branch. test/acl_hal_test.cpp:324:3: 15. path: Condition "!Utest::getCurrent()->assertTrue(acl_debug_env, "acl_debug_env", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 324)", taking true branch. test/acl_hal_test.cpp:326:3: 16. path: Condition "3 != debug_mode", taking true branch. test/acl_hal_test.cpp:326:3: 17. path: Falling through to end of if statement. test/acl_hal_test.cpp:329:3: 18. path: Condition "acl_debug_env", taking true branch. test/acl_hal_test.cpp:329:3: 19. path: Condition "!Utest::getCurrent()->assertTrue(acl_debug_env, "acl_debug_env", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 329)", taking true branch. test/acl_hal_test.cpp:331:3: 20. path: Condition "2 != debug_mode", taking true branch. test/acl_hal_test.cpp:331:3: 21. path: Falling through to end of if statement. test/acl_hal_test.cpp:332:3: 22. path: Condition "22UL /* sizeof (test_str) / sizeof (test_str[0]) - 1 */ != acl_print_debug_msg(test_str)", taking true branch. test/acl_hal_test.cpp:332:3: 23. path: Falling through to end of if statement. test/acl_hal_test.cpp:336:3: 24. path: Condition "0 != acl_print_debug_msg("")", taking true branch. test/acl_hal_test.cpp:336:3: 25. path: Falling through to end of if statement. test/acl_hal_test.cpp:339:3: 26. path: Condition "acl_debug_env", taking true branch. test/acl_hal_test.cpp:339:3: 27. path: Condition "!Utest::getCurrent()->assertTrue(acl_debug_env, "acl_debug_env", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 339)", taking true branch. test/acl_hal_test.cpp:341:3: 28. path: Condition "0 != debug_mode", taking false branch. test/acl_hal_test.cpp:342:3: 29. path: Condition "0 != acl_print_debug_msg(test_str)", taking true branch. test/acl_hal_test.cpp:342:3: 30. path: Falling through to end of if statement. test/acl_hal_test.cpp:346:3: 31. path: Condition "1 != hal->query_temperature(0, &temp)", taking false branch. test/acl_hal_test.cpp:347:3: 32. path: Condition "0 != temp", taking false branch. test/acl_hal_test.cpp:353:3: 33. path: Condition "size_returned < 1024", taking true branch. test/acl_hal_test.cpp:353:3: 34. path: Condition "!Utest::getCurrent()->assertTrue(size_returned < 1024, "size_returned < BUF_SIZE", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 353)", taking true branch. test/acl_hal_test.cpp:354:3: 35. path: Condition "strcmp(name, "Test Device") == 0", taking true branch. test/acl_hal_test.cpp:354:3: 36. path: Condition "!Utest::getCurrent()->assertTrue(strcmp(name, "Test Device") == 0, "strcmp(name, \"Test Device\") == 0", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 354)", taking true branch. test/acl_hal_test.cpp:356:3: 37. path: Condition "size_returned < 1024", taking true branch. test/acl_hal_test.cpp:356:3: 38. path: Condition "!Utest::getCurrent()->assertTrue(size_returned < 1024, "size_returned < BUF_SIZE", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 356)", taking true branch. test/acl_hal_test.cpp:357:3: 39. path: Condition "strcmp(name, "Intel(R) Corporation") == 0", taking true branch. test/acl_hal_test.cpp:357:3: 40. path: Condition "!Utest::getCurrent()->assertTrue(strcmp(name, "Intel(R) Corporation") == 0, "strcmp(name, \"Intel(R) Corporation\") == 0", "/__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/test/acl_hal_test.cpp", 357)", taking true branch. test/acl_hal_test.cpp:362:3: 41. overrun-buffer-arg: Overrunning buffer pointed to by "&temp_u64" of 1 8-byte elements by passing it to a function which accesses it at element index 1 (byte offset 15) using argument "2U". (The function pointer resolves to "acl_hal_mmd_get_profile_data".) src/acl_hal_mmd.cpp:2448:3: 41.1. path: Condition "physical_device_id < num_physical_devices", taking true branch. src/acl_hal_mmd.cpp:2449:3: 41.2. access_dbuff_in_call: Calling "acl_kernel_if_get_profile_data" indexes array "data" with index "length". src/acl_kernel_if.cpp:1870:3: 41.2.1. path: Condition "length > 0", taking true branch. src/acl_kernel_if.cpp:1872:5: 41.2.2. path: Condition "kern->io.printf", taking true branch. src/acl_kernel_if.cpp:1872:5: 41.2.3. path: Condition "kern->io.debug_verbosity > 0", taking true branch. src/acl_kernel_if.cpp:1878:5: 41.2.4. path: Condition "i < length", taking true branch. src/acl_kernel_if.cpp:1878:5: 41.2.5. loop_bounded_by_parm: "length" bounds loop condition "i < length". src/acl_kernel_if.cpp:1879:7: 41.2.6. index_parm_via_loop_bound: Pointer "data" is accessed by "i", whose upper bound is "length" in loop conditional "i < length". ```
ec429e9
to
61f3298
Compare
A variable was not being initialized causing Coverity to complain.
Fixes: