namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.08k stars 478 forks source link

WARN: cannot open record data: uftrace.data: No data available #1101

Open ansisatteka opened 4 years ago

ansisatteka commented 4 years ago

On Ubuntu 18.04.3 LTS X86_64 I have built suricata with -pg flag. However, the uftrace replay command fails:

$ uftrace -v replay
uftrace: reading uftrace.data/task.txt file
WARN: cannot open record data: uftrace.data: No data available

After digging deeper I noticed that the uftrace.data/pid.dat file was not created when I ran the uftrace record command:

$ ls uftrace.data/*
uftrace.data/default.opts            uftrace.data/libdl-2.27.so.sym    uftrace.data/libjansson.so.4.11.0.sym  uftrace.data/libnss3.so.sym         uftrace.data/libplds4.so.sym           uftrace.data/libz.so.1.2.11.sym
uftrace.data/info                    uftrace.data/libelf-0.170.so.sym  uftrace.data/libm-2.27.so.sym          uftrace.data/libnssutil3.so.sym     uftrace.data/libpthread-2.27.so.sym    uftrace.data/sid-aa04d0f36e04663d.map
uftrace.data/ld-2.27.so.sym          uftrace.data/libgcc_s.so.1.sym    uftrace.data/libmagic.so.1.0.0.sym     uftrace.data/libpcap.so.1.8.1.sym   uftrace.data/librt-2.27.so.sym         uftrace.data/suricata.sym
uftrace.data/libc-2.27.so.sym        uftrace.data/libhs.so.4.7.0.sym   uftrace.data/libnet.so.1.7.0.sym       uftrace.data/libpcre.so.3.13.3.sym  uftrace.data/libsuricata.so.0.0.0.sym  uftrace.data/task.txt
uftrace.data/libcap-ng.so.0.0.0.sym  uftrace.data/libhtp.so.2.0.0.sym  uftrace.data/libnspr4.so.sym           uftrace.data/libplc4.so.sym         uftrace.data/libyaml-0.so.2.0.5.sym

The uftrace record output:

$ uftrace -v record ./src/.libs/suricata
uftrace: checking binary ./src/.libs/suricata
uftrace: creating 2 thread(s) for recording
uftrace: using /usr/local/lib/libmcount.so library for tracing
mcount: initializing mcount library
plthook: setup PLT hooking "/home/aatteka/Git/suricata/src/.libs/suricata"
mcount: mcount setup done
mcount: new session started: 8e09a78e5d29cca8: suricata
Suricata 5.0.0-dev (1103000cf 2019-10-29)
<SURICATA HELP MESSAGE>
./src/.libs/suricata -c suricata.yaml -s signatures.rules -i eth0 

mcount: mcount trace finished
mcount: exit from libmcount
uftrace: child terminated with exit code: 1
uftrace: reading uftrace.data/task.txt file
uftrace: flushing /uftrace-8e09a78e5d29cca8-8350-000

I am able to successfully trace other processes than suricata, so I am wondering if this may have something to do with what suricata does? If it helps then shmem_buf->size is always zero when I trace suricata, and when I successfully trace other processes it is non-zero.

        if (shmem_buf->size) { <---- always 0 when tracing suricata
            /* shmem_buf will be unmapped */
            copy_to_buffer(shmem_buf, sess_id);
            return;
        }
honggyukim commented 4 years ago

Hi @ansisatteka,

Thanks for the report. I have tried to reproduce to the problem, but it seems that it works fine with suricata.

It'd be helpful to share how to reproduce the problem including source download, build, and tracing with uftrace.

Do you see the problem only on Ubuntu 18.04 LTS version?