iovisor/ply

Assertion fails in tracepoint_parse

ariel-miculas opened this issue · 1 comments

ply: provider/tracepoint.c:198: tracepoint_parse: Assertion `offs == type_offsetof(t, t->sou.fields[n - 1].name)' failed.

I've tried this workaround, but it didn't work:

	/* Find all basic scalars. */
	/* if (!strcmp(str, "char")) */
	/* 	return explicit_sign ? (sign ? &t_schar : &t_uchar) : &t_char; */
	/* else if (!strcmp(str, "short")) */
	/* 	return explicit_sign ? (sign ? &t_sshort : &t_ushort) : &t_short; */
	/* else if (!strcmp(str, "int")) */
	/* 	return explicit_sign ? (sign ? &t_sint : &t_uint) : &t_int; */
	/* else if (!strcmp(str, "long")) */
	/* 	return explicit_sign ? (sign ? &t_slong : &t_ulong) : &t_long; */
	/* else if (!strcmp(str, "long long")) */
	/* 	return explicit_sign ? (sign ? &t_sllong : &t_ullong) : &t_llong; */

Format:

~# cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/format
name: sys_enter
ID: 19
format:
        field:unsigned short common_type;       offset:0;       size:2; signed:0;
        field:unsigned char common_flags;       offset:2;       size:1; signed:0;
        field:unsigned char common_preempt_count;       offset:3;       size:1; signed:0;
        field:int common_pid;   offset:4;       size:4; signed:1;
        field:unsigned short common_migrate_disable;    offset:8;       size:2; signed:0;
        field:unsigned short common_padding;    offset:10;      size:2; signed:0;

        field:long id;  offset:16;      size:4; signed:1;
        field:unsigned long args[6];    offset:20;      size:24;        signed:0;

print fmt: "NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)", REC->id, REC->args[0], REC->args[1], REC->args[2], REC->args[3], REC->args[4], REC->args[5]

I've added some logs:

~# ply 'tracepoint:raw_syscalls/sys_enter { @[pid, comm] = count(); }'
name: common_type, offs: 0, type_offsetof: 0
name: common_flags, offs: 2, type_offsetof: 2
name: common_preempt_count, offs: 3, type_offsetof: 3
name: common_pid, offs: 4, type_offsetof: 4
name: common_migrate_disable, offs: 8, type_offsetof: 8
name: common_padding, offs: 10, type_offsetof: 10
name: id, offs: 16, type_offsetof: 12
ply: provider/tracepoint.c:198: tracepoint_parse: Assertion `offs == type_offsetof(t, t->sou.fields[n - 1].name)' failed.
Aborted (core dumped)

It's different than mine. My event format is properly aligned and packed:

$ sudo cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/format
name: sys_enter
ID: 341
format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;

	field:long id;	offset:8;	size:8;	signed:1;
	field:unsigned long args[6];	offset:16;	size:48;	signed:0;
...

Maybe you are running a custom kernel? Then you need to fix the kernel to increase the padding.