XRT
XRT copied to clipboard
Fix (1) realloc error handling (2) nullptr->member accesses (3) new-delete type mismatches
Problem solved by the commit
realloc() returns a NULL if reallocation was not successful. This was not handled properly (by returning new_size
after conditional execution free(temp)
.
More info on realloc
:
How problem was solved, alternative solutions (if any) and why they were rejected
Returning the original size if reallocation was unsuccessful.
Risks (if any) associated the changes in the commit
I do not know. I did not test the reallocation fail case.
What has been tested and how, request additional testing if necessary
I did not carry any tests. I request additional testing.
Documentation impact (if any)
I do not know.
Can one of the admins verify this patch?
ok to test
Build Passed!
I added further changes which fix nullptr->member accesses new-delete type mismatches. I explained them in commit messages.
I stumbled upon them while compiling with GCC 12.1, which probably introduced some static analysis-related warnings. These fixes are only related to warnings which were treated as errors due to -Werror
.
On my OS build.sh
succeeded, but I did not carry out further tests.
Build Passed!
Build Failed! :(
Build Failed! :(
Probably introduced due to the recent.commits, I will look into that.
Ok, it seems to build on my OS. Can you retest please?
Build Passed!
I supplemented a driver-related patch for newer kernels, so I updated the header for this PR. Additionally testes these patches on an U280 using xbutil validate
on the kernel 5.19.2.
Build Failed! :(
I do not get any build errors. Can you please give some details?
There are compilation errors from edge platform build. Here is the log:
06:50:51 | CC [M] /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_cu_xgq.o 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_bo.c:22:10: fatal error: linux/iosys-map.h: No such file or directory 06:50:51 | 22 | #include <linux/iosys-map.h> 06:50:51 | | ^~~~~~~~~~~~~~~~~~~ 06:50:51 | compilation terminated. 06:50:51 | make[3]: *** [/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-source/scripts/Makefile.build:278: /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_bo.o] Error 1 06:50:51 | make[3]: *** Waiting for unfinished jobs.... 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c: In function 'populate_slot_specific_sec': 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c:1175:13: warning: unused variable 'slot_id' [-Wunused-variable] 06:50:51 | 1175 | int slot_id = slot->slot_idx; 06:50:51 | | ^~~~~~~ 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c:1174:34: warning: unused variable 'ret' [-Wunused-variable] 06:50:51 | 1174 | int ret = 0; 06:50:51 | | ^~~ 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c: In function 'zocl_xclbin_set_dtbo_path': 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c:1744:17: warning: ignoring return value of 'copy_from_user' declared with attribute 'warn_unused_result' [-Wunused-result] 06:50:51 | 1744 | copy_from_user(path, dtbo_path, len); 06:50:51 | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 06:50:51 | make[2]: *** [/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-source/Makefile:1868: /opt/xrt/src/runtime_src/core/edge/drm/zocl] Error 2 06:50:51 | make[2]: Leaving directory '/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-build-artifacts' 06:50:51 | make[1]: Leaving directory '/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-source' 06:50:51 | make[1]: *** [Makefile:219: __sub-make] Error 2 06:50:51 | ERROR: oe_runmake failed 06:50:51 | WARNING: /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411:200 exit 1 from 'exit 1' 06:50:51 | WARNING: Backtrace (BB generated script): 06:50:51 | make: *** [Makefile:72: modules] Error 2 06:50:51 | #1: bbfatal_log, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 200 06:50:51 | #2: die, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 171 06:50:51 | #3: oe_runmake, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 166 06:50:51 | #4: module_do_compile, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 155 06:50:51 | #5: do_compile, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 149 06:50:51 | #6: main, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 200 06:50:51 NOTE: recipe zocl-202220.2.14.0-r0: task do_compile: Failed 06:50:51 ERROR: Task (/opt/xrt/build/aarch64/components/yocto/layers/meta-xilinx/meta-xilinx-core/recipes-xrt/zocl/zocl_git.bb:do_compile) failed with exit code '1' 06:50:52 NOTE: recipe linux-xlnx-5.15.36+gitAUTOINC+32a31b33e6-r0: task do_package: Succeeded 06:50:55 NOTE: Tasks Summary: Attempted 945 tasks of which 816 didn't need to be rerun and 1 failed. 06:50:55 06:50:55 Summary: 1 task failed: 06:50:55 /opt/xrt/build/aarch64/components/yocto/layers/meta-xilinx/meta-xilinx-core/recipes-xrt/zocl/zocl_git.bb:do_compile 06:50:55 Summary: There were 9 WARNING messages shown. 06:50:55 Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
Thanks for the improvement. The kernel part is completely unrelated to the first problem, so it should be in another PR. Also your change needs to be guarded by some kernel version macros to be only used for the kernel versions it makes sense and not break compilation for older kernels.
There are compilation errors from edge platform build. Here is the log:
06:50:51 | CC [M] /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_cu_xgq.o 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_bo.c:22:10: fatal error: linux/iosys-map.h: No such file or directory 06:50:51 | 22 | #include <linux/iosys-map.h> 06:50:51 | | ^~~~~~~~~~~~~~~~~~~ 06:50:51 | compilation terminated. 06:50:51 | make[3]: *** [/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-source/scripts/Makefile.build:278: /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_bo.o] Error 1 06:50:51 | make[3]: *** Waiting for unfinished jobs.... 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c: In function 'populate_slot_specific_sec': 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c:1175:13: warning: unused variable 'slot_id' [-Wunused-variable] 06:50:51 | 1175 | int slot_id = slot->slot_idx; 06:50:51 | | ^~~~~~~ 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c:1174:34: warning: unused variable 'ret' [-Wunused-variable] 06:50:51 | 1174 | int ret = 0; 06:50:51 | | ^~~ 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c: In function 'zocl_xclbin_set_dtbo_path': 06:50:51 | /opt/xrt/src/runtime_src/core/edge/drm/zocl/zocl_xclbin.c:1744:17: warning: ignoring return value of 'copy_from_user' declared with attribute 'warn_unused_result' [-Wunused-result] 06:50:51 | 1744 | copy_from_user(path, dtbo_path, len); 06:50:51 | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 06:50:51 | make[2]: *** [/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-source/Makefile:1868: /opt/xrt/src/runtime_src/core/edge/drm/zocl] Error 2 06:50:51 | make[2]: Leaving directory '/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-build-artifacts' 06:50:51 | make[1]: Leaving directory '/tmp/aarch64-2022.08.22-12.36.09-LqY/work-shared/zynqmp-generic/kernel-source' 06:50:51 | make[1]: *** [Makefile:219: __sub-make] Error 2 06:50:51 | ERROR: oe_runmake failed 06:50:51 | WARNING: /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411:200 exit 1 from 'exit 1' 06:50:51 | WARNING: Backtrace (BB generated script): 06:50:51 | make: *** [Makefile:72: modules] Error 2 06:50:51 | #1: bbfatal_log, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 200 06:50:51 | #2: die, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 171 06:50:51 | #3: oe_runmake, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 166 06:50:51 | #4: module_do_compile, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 155 06:50:51 | #5: do_compile, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 149 06:50:51 | #6: main, /tmp/aarch64-2022.08.22-12.36.09-LqY/work/zynqmp_generic-xilinx-linux/zocl/202220.2.14.0-r0/temp/run.do_compile.81411, line 200 06:50:51 NOTE: recipe zocl-202220.2.14.0-r0: task do_compile: Failed 06:50:51 ERROR: Task (/opt/xrt/build/aarch64/components/yocto/layers/meta-xilinx/meta-xilinx-core/recipes-xrt/zocl/zocl_git.bb:do_compile) failed with exit code '1' 06:50:52 NOTE: recipe linux-xlnx-5.15.36+gitAUTOINC+32a31b33e6-r0: task do_package: Succeeded 06:50:55 NOTE: Tasks Summary: Attempted 945 tasks of which 816 didn't need to be rerun and 1 failed. 06:50:55 06:50:55 Summary: 1 task failed: 06:50:55 /opt/xrt/build/aarch64/components/yocto/layers/meta-xilinx/meta-xilinx-core/recipes-xrt/zocl/zocl_git.bb:do_compile 06:50:55 Summary: There were 9 WARNING messages shown. 06:50:55 Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
This is coding issue. The change can't be merged until this is fixed.
The kernel part is completely unrelated to the first problem, so it should be in another PR.
You are right Ronan, the PR grew too much. For me this PR in overall enables compilation in recent kernels and GCC, so the kernel- and GCC-related fixes are in the same category. If the code owners desire I can split either
- kernel- and GCC-related commits or
- the
realloc
problem from other commits.
Also your change needs to be guarded by some kernel version macros to be only used for the kernel versions it makes sense and not break compilation for older kernels.
I am not interested in supporting older kernels, but still I wanted to give something back. Moreover I do not have access to the Zocl environment. It would be better if you could support the backwards-compatibility work.
Build Failed! :(
retest this please
You are right Ronan, the PR grew too much. For me this PR in overall enables compilation in recent kernels and GCC, so the kernel- and GCC-related fixes are in the same category. If the code owners desire I can split either
- kernel- and GCC-related commits or
- the realloc problem from other commits.
Usually we split kernel and user-mode PR. At the end, the goal of several smaller PRs is to be able to revert quickly in case of problem. So we are now more on 3 PRs. ;-)
Build Passed!
So we are now more on 3 PRs. ;-)
Ok I will split them in (1) the memalloc bug (2) kernel part (3) user mode part.
Created the split PRs. Closing.