Bug 392487 - Created file is not compatible with heaptrack
Summary: Created file is not compatible with heaptrack
Status: RESOLVED FIXED
Alias: None
Product: Heaptrack
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Milian Wolff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-29 13:43 UTC by Jasem Mutlaq
Modified: 2018-04-20 13:58 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
heaptrack cat (8.42 KB, text/plain)
2018-04-14 19:57 UTC, Jasem Mutlaq
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jasem Mutlaq 2018-03-29 13:43:12 UTC
Just compiled heaptrack from GIT master today and then proceeded to try to find memory leaks in my application. Since it is a child process, I started it separately and then got its PID and ran heaptrack. After finishing, I tried to open the file as instructed by heaptrack but then it complained about incompatible file version.

jasem@jasem-neon:~/Projects/build/heaptrack$ heaptrack --pid 7523

/usr/bin/heaptrack: 174: [: FALSE: unexpected operator
heaptrack output will be written to "/home/jasem/Projects/build/heaptrack/heaptrack.indi_eqmod_tele.7571.gz"
injecting heaptrack into application via GDB, this might take some time...
injection finished
heaptrack stats:
        allocations:            0
        leaked allocations:     0
        temporary allocations:  0
removing heaptrack injection via GDB, this might take some time...
Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
warning: process 7523 is a zombie - the process has already terminated
ptrace: Operation not permitted.
No symbol table is loaded.  Use the "file" command.
The program is not being run.
Heaptrack finished! Now run the following to investigate the data:

  heaptrack --analyze "/home/jasem/Projects/build/heaptrack/heaptrack.indi_eqmod_tele.7571.gz"
jasem@jasem-neon:~/Projects/build/heaptrack$ heaptrack --analyze "/home/jasem/Projects/build/heaptrack/heaptrack.indi_eqmod_tele.7571.gz"
The data file has version 2 and was written by heaptrack version 10000)
This is not compatible with this build of heaptrack (version 10000), which can read file format version 1 and below
jasem@jasem-neon:~/Projects/build/heaptrack$ ls -l "/home/jasem/Projects/build/heaptrack/heaptrack.indi_eqmod_tele.7571.gz"
-rw-rw-r-- 1 jasem jasem 512108 Mar 29 16:34 /home/jasem/Projects/build/heaptrack/heaptrack.indi_eqmod_tele.7571.gz
jasem@jasem-neon:~/Projects/build/heaptrack$ heaptrack --analyze "/home/jasem/Projects/build/heaptrack/heaptrack.indi_eqmod_tele.7571.gz"
The data file has version 2 and was written by heaptrack version 10000)
This is not compatible with this build of heaptrack (version 10000), which can read file format version 1 and below
Comment 1 Milian Wolff 2018-03-30 19:22:45 UTC
Probably a bug I introduced with the addition of zstd support. What shell do you use? Can you paste the contents of `cat $(which heaptrack)` please - I want to double-check what it generated.

To workaround this, install zstd development headers, it should both fix this and make heaptrack faster too :)
Comment 2 Milian Wolff 2018-04-03 14:21:15 UTC
I think I solved this via

commit 7ae3f595a0ea49abd4b8ecd8a7be2b362e0fa916
Author: Milian Wolff <milian.wolff@kdab.com>
Date:   Tue Apr 3 15:30:56 2018 +0200

    Make heaptrack.sh file compatible with dash
    
    Don't use the bashism == to compare strings, use = instead.
    
    BUG: 392487
Comment 3 Jasem Mutlaq 2018-04-14 19:57:23 UTC
Created attachment 112029 [details]
heaptrack cat
Comment 4 Jasem Mutlaq 2018-04-14 19:58:06 UTC
Nope, I just git pulled and built with zstd support and exactly the same problem on 16.04. I attached the output as you require but it's exactly same error message.
Comment 5 Milian Wolff 2018-04-16 08:06:32 UTC
do you still see this error:

/usr/bin/heaptrack: 174: [: FALSE: unexpected operator

?

What does this give you in your shell:

echo $SHELL
if [ "TRUE" = "TRUE" ] && [ ! -z "$(which zstd)" ]; then echo "works"; fi
Comment 6 Milian Wolff 2018-04-16 18:38:34 UTC
Oh and one more question: Can you actually attach via GDB? E.g. this part of the message makes me wonder:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf

Try to run `gdb --pid ...` and see if that works for you.
Comment 7 Jasem Mutlaq 2018-04-20 13:46:13 UTC
I installed zstd on 16.04 machine but now getting compile errors:

https://paste.kde.org/plj20ityd
Comment 8 Jasem Mutlaq 2018-04-20 13:58:07 UTC
Ok it appears I need to run: sudo apt-get install zstd which would install the correct libraries (I used libzstd-dev before which installed older version). At any rate, now it creates zst file.

It now finally works!