The leak-check tool does not show the information of source code and line number

I tried to use the following samples.

My environment is as follows.

  • CPU arch: x86_64
  • Ubuntu 22.04
  • CUDA 12.1
  • Compute Sanitizer 2023.1.0
  • NVIDIA Driver 530.30.02

At first, I used memcheck_demo.

cd Memcheck
dbg=1 make
make run_leakcheck

As a result, I could check memory leak.
But, this tool does not show the information of source code and line number.
Is this expected behavior?

========= Leaked 1,024 bytes at 0x7f298bc00000
=========     Saved host backtrace up to driver entry point at allocation time
=========     Host Frame: [0x2b9d27]
=========                in /lib/x86_64-linux-gnu/libcuda.so.1
=========     Host Frame:__cudart600 [0x43ace]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:__cudart609 [0x10f2b]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:cudaMalloc [0x517c2]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:main [0xae3d]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:../sysdeps/nptl/libc_start_call_main.h:58:__libc_start_call_main [0x29d90]
=========                in /lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:../csu/libc-start.c:379:__libc_start_main [0x29e40]
=========                in /lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:_start [0xab05]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo

I checked the document of Compute Sanitizer.
But, I could not find the information from the known issue and limitation.

On the other hands, racecheck tool shows the information of source code and line number.

cd Racecheck
dbg=1 make
make run_block_error
========= COMPUTE-SANITIZER
========= Error: Race reported between Write access at 0x400 in /home/dandelion/compute-sanitizer-samples/Racecheck/block_error.cu:41:sumKernel(int *, int *)
=========     and Read access at 0x700 in /home/dandelion/compute-sanitizer-samples/Racecheck/block_error.cu:51:sumKernel(int *, int *) [508 hazards]
========= 
========= RACECHECK SUMMARY: 1 hazard displayed (1 error, 0 warnings)

It seems you are missing debug information in your host binary. Adding GCC compilation flag -g will address the issue.

I add -g option.
As a result, source code and line number are reported.

$ dbg=1 make
/usr/local/cuda/bin/nvcc -ccbin g++ -I/usr/local/cuda/include -MMD -G -g -Xcompiler -rdynamic -c memcheck_demo.cu
/usr/local/cuda/bin/nvcc -ccbin g++  -o memcheck_demo memcheck_demo.o
rm memcheck_demo.o
========= Leaked 1,024 bytes at 0x7fc175c00000
=========     Saved host backtrace up to driver entry point at allocation time
=========     Host Frame: [0x2b9d27]
=========                in /lib/x86_64-linux-gnu/libcuda.so.1
=========     Host Frame:__cudart600 [0x43ace]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:__cudart609 [0x10f2b]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:cudaMalloc [0x517c2]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:/home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo.cu:67:main [0xae3d]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
=========     Host Frame:../sysdeps/nptl/libc_start_call_main.h:58:__libc_start_call_main [0x29d90]
=========                in /lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:../csu/libc-start.c:379:__libc_start_main [0x29e40]
=========                in /lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:_start [0xab05]
=========                in /home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo
========= 
========= LEAK SUMMARY: 1024 bytes leaked in 1 allocations

Host Frame:/home/dandelion/compute-sanitizer-samples/Memcheck/memcheck_demo.cu:67:main [0xae3d]

This tool reports memcheck_demo.cu:67. Is this report correct?

Screenshot from 2023-09-06 11-21-05

Based on your screenshot, line reported should be 65. Can you please double-check the source file you used for compilation is unchanged using git diff memcheck_demo.cu?

There is no change in memcheck_demo.cu.

Thanks for these precisions, I can reproduce this locally. I will file a bug internally to address this issue. Thanks!

Thank you for your reply.

This bug has been addressed for our next CUDA release. Thank you for reporting this issue!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.