wkz / ply

Light-weight Dynamic Tracer for Linux
https://wkz.github.io/ply
GNU General Public License v2.0
402 stars 156 forks source link

segmentation fault in if statement #11

Closed ccb3 closed 6 years ago

ccb3 commented 6 years ago

As one example, I want to print a header the first time I enter a probe. In order to do that I check if a map h[0] is set and if it is not i should print the header information. This works if I use "if (h[0])" but not the other way around, i.e. using "if (!h[0])" instead. This gives segmentation fault. My example is shown below

kretprobe:vfs_read
{
        if (!h[0])
                printf("%-18s %6s %6s %16s %10s\n", "Time",  "PID", "UID", "COMM", "BYTES");

        printf("%v %6d %6d %16s %10d\n", walltime, pid, uid, comm, retval);
        h[0] = 1;
}
wkz commented 6 years ago

Thanks for reporting this!