honggyukim / heaptrace

a tool that collects and reports heap allocated memory
GNU General Public License v2.0
13 stars 3 forks source link

Report not printing backtrace issue #10

Open Bojun-Seo opened 1 year ago

Bojun-Seo commented 1 year ago

In some cases,(64-bits for kernel, and 32-bits for user environment)

[heaptrace] dump allocation status for /proc/1234/maps (caeaq)
=== backtrace #1 === [count/peak: 118838/118842] [size/peak: 163.510 MB/168.129 MB] [age: 28 mins 31 secs]                                             

Report doesn't print backtraces.

I checked the reason and found that backtrace function, https://man7.org/linux/man-pages/man3/backtrace.3.html which is called inside record_backtrace function, returns zero.

honggyukim commented 1 year ago

Hmm.. I don't really understand what the problem is. Is this error shown only in 64-bit kernel and 32-bit user environment?

Bojun-Seo commented 1 year ago

The problem is that it prints only the report I attached(no backtraces are printed) I only found this issue happened on 64-bit arm chip with 64-bit kernel and 32-bit user environment. I will check whether I could share more information about test environment.

Bojun-Seo commented 1 year ago

I found the way to reproduce this issue.

  1. Flash raspberry-pi 32bits OS on raspberry-pi4 (I used rpi-imager)
    $ cat /etc/issue.net
    Raspbian GNU/Linux 11
    $ uname -r
    6.1.21-v8+
  2. Clone heaptrace and build it on target
  3. Run ./heaptrace samples/sample_leak.out Will generate following result
    
    $ ./heaptrace samples/sample_leak.out
    [heaptrace] initialized for /proc/4862/maps (sample_leak.out)
    [heaptrace]   finalized for /proc/4862/maps (sample_leak.out)
    =================================================================
    [heaptrace] dump allocation sorted by 'size' for /proc/4862/maps (sample_leak.out)
    === backtrace #1 === [count/peak: 1/2] [size/peak: 4 bytes/1.0 MB] [age: 884.292 us]

[heaptrace] heap traced num of backtrace : 1 [heaptrace] heap traced allocation size : 4 bytes [heaptrace] allocator info (virtual) : 135.168 KB [heaptrace] allocator info (resident) : 22.712 KB [heaptrace] statm info (VSS/RSS/shared) : 4.370 MB / 2.801 MB / 2.646 MB

honggyukim commented 1 year ago

Hi, I don't have a raspberry-pi board so can this be reproduced in x86_64 machine in some ways?

Bojun-Seo commented 1 year ago

I'll let you know, if I found a way to reproduce this issue in x86_64 machine.

honggyukim commented 1 year ago

That would be helpful. Please let me know how to reproduce it in host machine.