* [PATCH] libtraceevent utest: exit test if mmap fails
@ 2026-05-26 18:42 Sudip Mukherjee
2026-05-29 18:41 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Sudip Mukherjee @ 2026-05-26 18:42 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel, Sudip Mukherjee
CU_TEST() continues execution even if the test fails. It just records
that the test has failed and moves on.
So, when libtraceevent is built in a chroot, it can open
/sys/kernel/btf/vmlinux but fails in mmap stage and since CU_TEST()
does not stop so we get a segfault when tep_load_btf() tries to use
the mapped buffer.
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
utest/traceevent-utest.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/utest/traceevent-utest.c b/utest/traceevent-utest.c
index b62411c..547619d 100644
--- a/utest/traceevent-utest.c
+++ b/utest/traceevent-utest.c
@@ -397,6 +397,12 @@ static void test_btf_read(void)
CU_TEST(fstat(fd, &st) == 0);
buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (buf == MAP_FAILED) {
+ printf("kernel has btf, but it might be a chroot and mmap has failed\n");
+ close(fd);
+ return;
+ }
+
CU_TEST(buf != MAP_FAILED);
CU_TEST(tep_load_btf(test_tep, buf, st.st_size) == 0);
--
2.39.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] libtraceevent utest: exit test if mmap fails
2026-05-26 18:42 [PATCH] libtraceevent utest: exit test if mmap fails Sudip Mukherjee
@ 2026-05-29 18:41 ` Steven Rostedt
2026-06-15 19:25 ` Sudip Mukherjee
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2026-05-29 18:41 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: linux-trace-devel, Emil Thorsoe
On Tue, 26 May 2026 19:42:19 +0100
Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> CU_TEST() continues execution even if the test fails. It just records
> that the test has failed and moves on.
> So, when libtraceevent is built in a chroot, it can open
> /sys/kernel/btf/vmlinux but fails in mmap stage and since CU_TEST()
> does not stop so we get a segfault when tep_load_btf() tries to use
> the mapped buffer.
>
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Thanks, but the real fix is here and I'm applying that one:
https://lore.kernel.org/all/d6e07cd6-cb78-4119-a048-920ca58b4830@tuxera.com/
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libtraceevent utest: exit test if mmap fails
2026-05-29 18:41 ` Steven Rostedt
@ 2026-06-15 19:25 ` Sudip Mukherjee
2026-06-16 20:48 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Sudip Mukherjee @ 2026-06-15 19:25 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-trace-devel, Emil Thorsoe
Hi Steve,
On Fri, 29 May 2026 at 19:41, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Tue, 26 May 2026 19:42:19 +0100
> Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
>
> > CU_TEST() continues execution even if the test fails. It just records
> > that the test has failed and moves on.
> > So, when libtraceevent is built in a chroot, it can open
> > /sys/kernel/btf/vmlinux but fails in mmap stage and since CU_TEST()
> > does not stop so we get a segfault when tep_load_btf() tries to use
> > the mapped buffer.
> >
> > Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
>
> Thanks, but the real fix is here and I'm applying that one:
>
> https://lore.kernel.org/all/d6e07cd6-cb78-4119-a048-920ca58b4830@tuxera.com/
Tried it today, and the test still fails for me.
Suite: traceevent library
Test: parse dynamic string event ...irq=0 handler=hellopassed
Test: parse old dynamic string event ...irq=0 handler=hellopassed
Test: parse full cpumask ...cpumask=0-63passed
Test: parse empty cpumask ...cpumask=passed
Test: parse half-filled cpumask
...cpumask=0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62passed
Test: parse cpumask spanning 2 bytes ...cpumask=0,15passed
Test: parse cpumask spanning 3 bytes ...cpumask=0,23passed
Test: parse cpumask spanning all bytes ...cpumask=0,63passed
Test: parse sizeof() 8byte values ...int=4 unsigned=4 unsigned int=4
long=8 unsigned long=8 long long=8 unsigned long long=8 s4=4 u4=4 s8=8
u8=8passed
Test: parse sizeof() 4byte values ...int=4 unsigned=4 unsigned int=4
long=4 unsigned long=4 long long=8 unsigned long long=8 s4=4 u4=4 s8=8
u8=8passed
Test: parse sizeof() no long size defined ...[FAILED TO PARSE] s4=0
u4=0 s8=0 u8=0x0passed
Test: read BTF ...FAILED
1. traceevent-utest.c:410 - read(fd, buf, st.st_size) == st.st_size
2. traceevent-utest.c:412 - tep_load_btf(test_tep, buf, st.st_size) == 0
3. traceevent-utest.c:429 - strcmp(s->buffer,
"getname_flags(filename=0x7ffe7d33f3d0, flags=0)\n") == 0
Run Summary: Type Total Ran Passed Failed Inactive
suites 1 1 n/a 0 0
tests 12 12 11 1 0
asserts 46 46 43 3 n/a
--
Regards
Sudip
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libtraceevent utest: exit test if mmap fails
2026-06-15 19:25 ` Sudip Mukherjee
@ 2026-06-16 20:48 ` Steven Rostedt
2026-11-07 16:24 ` Sudip Mukherjee
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2026-06-16 20:48 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: linux-trace-devel, Emil Thorsoe
On Mon, 15 Jun 2026 20:25:08 +0100
Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> Hi Steve,
>
> On Fri, 29 May 2026 at 19:41, Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > On Tue, 26 May 2026 19:42:19 +0100
> > Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> >
> > > CU_TEST() continues execution even if the test fails. It just records
> > > that the test has failed and moves on.
> > > So, when libtraceevent is built in a chroot, it can open
> > > /sys/kernel/btf/vmlinux but fails in mmap stage and since CU_TEST()
> > > does not stop so we get a segfault when tep_load_btf() tries to use
> > > the mapped buffer.
> > >
> > > Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> >
> > Thanks, but the real fix is here and I'm applying that one:
> >
> > https://lore.kernel.org/all/d6e07cd6-cb78-4119-a048-920ca58b4830@tuxera.com/
>
> Tried it today, and the test still fails for me.
Thanks for letting me know. I currently just started a new job and I'm
a bit overwhelmed. It may be a couple more weeks before I get to this.
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libtraceevent utest: exit test if mmap fails
2026-06-16 20:48 ` Steven Rostedt
@ 2026-11-07 16:24 ` Sudip Mukherjee
2026-11-07 21:20 ` Steven Rostedt
0 siblings, 1 reply; 7+ messages in thread
From: Sudip Mukherjee @ 2026-11-07 16:24 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-trace-devel, Emil Thorsoe
Hi Steve,
On Tue, Jun 16, 2026 at 04:48:12PM -0400, Steven Rostedt wrote:
> On Mon, 15 Jun 2026 20:25:08 +0100
> Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
>
> > Hi Steve,
> >
> > On Fri, 29 May 2026 at 19:41, Steven Rostedt <rostedt@goodmis.org> wrote:
> > >
> > > On Tue, 26 May 2026 19:42:19 +0100
> > > Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> > >
> > > > CU_TEST() continues execution even if the test fails. It just records
> > > > that the test has failed and moves on.
> > > > So, when libtraceevent is built in a chroot, it can open
> > > > /sys/kernel/btf/vmlinux but fails in mmap stage and since CU_TEST()
> > > > does not stop so we get a segfault when tep_load_btf() tries to use
> > > > the mapped buffer.
> > > >
> > > > Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> > >
> > > Thanks, but the real fix is here and I'm applying that one:
> > >
> > > https://lore.kernel.org/all/d6e07cd6-cb78-4119-a048-920ca58b4830@tuxera.com/
> >
> > Tried it today, and the test still fails for me.
>
> Thanks for letting me know. I currently just started a new job and I'm
> a bit overwhelmed. It may be a couple more weeks before I get to this.
Not sure if you had a chance to look at it. I was looking at it now while
updating the Debian package. It seems like btf_init() is failing when its
doing if (btf->hdr->hdr_len < sizeof(*btf->hdr)). Adding a debug there shows,
btf->hdr->hdr_len is 24 whereas sizeof(*btf->hdr) is 32.
Tried on a chroot and also on a VM, both shows the same problem in Debian.
--
Regards
Sudip
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libtraceevent utest: exit test if mmap fails
2026-11-07 16:24 ` Sudip Mukherjee
@ 2026-11-07 21:20 ` Steven Rostedt
2026-11-08 11:02 ` Sudip Mukherjee
0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2026-11-07 21:20 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: linux-trace-devel, Emil Thorsoe
On Sat, 7 Nov 2026 16:24:32 +0000
Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> Hi Steve,
>
> On Tue, Jun 16, 2026 at 04:48:12PM -0400, Steven Rostedt wrote:
> > On Mon, 15 Jun 2026 20:25:08 +0100
> > Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> >
> > > Hi Steve,
> > >
> > > On Fri, 29 May 2026 at 19:41, Steven Rostedt <rostedt@goodmis.org> wrote:
> > > >
> > > > On Tue, 26 May 2026 19:42:19 +0100
> > > > Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> > > >
> > > > > CU_TEST() continues execution even if the test fails. It just records
> > > > > that the test has failed and moves on.
> > > > > So, when libtraceevent is built in a chroot, it can open
> > > > > /sys/kernel/btf/vmlinux but fails in mmap stage and since CU_TEST()
> > > > > does not stop so we get a segfault when tep_load_btf() tries to use
> > > > > the mapped buffer.
> > > > >
> > > > > Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> > > >
> > > > Thanks, but the real fix is here and I'm applying that one:
> > > >
> > > > https://lore.kernel.org/all/d6e07cd6-cb78-4119-a048-920ca58b4830@tuxera.com/
> > >
> > > Tried it today, and the test still fails for me.
> >
> > Thanks for letting me know. I currently just started a new job and I'm
> > a bit overwhelmed. It may be a couple more weeks before I get to this.
>
> Not sure if you had a chance to look at it. I was looking at it now while
> updating the Debian package. It seems like btf_init() is failing when its
> doing if (btf->hdr->hdr_len < sizeof(*btf->hdr)). Adding a debug there shows,
> btf->hdr->hdr_len is 24 whereas sizeof(*btf->hdr) is 32.
>
> Tried on a chroot and also on a VM, both shows the same problem in Debian.
>
Bah, because I thought the fix was elsewhere I marked it as
"superseded" and forgot I did that. When you said it was different, I
was traveling and didn't bother to check patchwork to reset it back to
New.
https://patchwork.kernel.org/project/linux-trace-devel/patch/20260526184219.408223-1-sudipm.mukherjee@gmail.com/
If it's not visible in patchwork, it's not visible to me :-/
I'll go and set it now to New. Thanks for keeping up on it.
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] libtraceevent utest: exit test if mmap fails
2026-11-07 21:20 ` Steven Rostedt
@ 2026-11-08 11:02 ` Sudip Mukherjee
0 siblings, 0 replies; 7+ messages in thread
From: Sudip Mukherjee @ 2026-11-08 11:02 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-trace-devel, Emil Thorsoe
On Sat, 7 Nov 2026 at 21:20, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Sat, 7 Nov 2026 16:24:32 +0000
> Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
>
> > Hi Steve,
> >
> > On Tue, Jun 16, 2026 at 04:48:12PM -0400, Steven Rostedt wrote:
> > > On Mon, 15 Jun 2026 20:25:08 +0100
> > > Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> > >
> > > > Hi Steve,
> > > >
> > > > On Fri, 29 May 2026 at 19:41, Steven Rostedt <rostedt@goodmis.org> wrote:
> > > > >
> > > > > On Tue, 26 May 2026 19:42:19 +0100
> > > > > Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> > > > >
> > > > > > CU_TEST() continues execution even if the test fails. It just records
> > > > > > that the test has failed and moves on.
> > > > > > So, when libtraceevent is built in a chroot, it can open
> > > > > > /sys/kernel/btf/vmlinux but fails in mmap stage and since CU_TEST()
> > > > > > does not stop so we get a segfault when tep_load_btf() tries to use
> > > > > > the mapped buffer.
> > > > > >
> > > > > > Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> > > > >
> > > > > Thanks, but the real fix is here and I'm applying that one:
> > > > >
> > > > > https://lore.kernel.org/all/d6e07cd6-cb78-4119-a048-920ca58b4830@tuxera.com/
> > > >
> > > > Tried it today, and the test still fails for me.
> > >
> > > Thanks for letting me know. I currently just started a new job and I'm
> > > a bit overwhelmed. It may be a couple more weeks before I get to this.
> >
> > Not sure if you had a chance to look at it. I was looking at it now while
> > updating the Debian package. It seems like btf_init() is failing when its
> > doing if (btf->hdr->hdr_len < sizeof(*btf->hdr)). Adding a debug there shows,
> > btf->hdr->hdr_len is 24 whereas sizeof(*btf->hdr) is 32.
> >
> > Tried on a chroot and also on a VM, both shows the same problem in Debian.
> >
>
> Bah, because I thought the fix was elsewhere I marked it as
> "superseded" and forgot I did that. When you said it was different, I
> was traveling and didn't bother to check patchwork to reset it back to
> New.
>
> https://patchwork.kernel.org/project/linux-trace-devel/patch/20260526184219.408223-1-sudipm.mukherjee@gmail.com/
The patch which superseded it seems to be correct, mmap fails and it
copies the content to a buffer and uses that buffer.
But for some reason the len and size does not match. So decided to
flag it to you instead of disabling the test in Debian package. So, it
should ideally be a new issue.
--
Regards
Sudip
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-08 11:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 18:42 [PATCH] libtraceevent utest: exit test if mmap fails Sudip Mukherjee
2026-05-29 18:41 ` Steven Rostedt
2026-06-15 19:25 ` Sudip Mukherjee
2026-06-16 20:48 ` Steven Rostedt
2026-11-07 16:24 ` Sudip Mukherjee
2026-11-07 21:20 ` Steven Rostedt
2026-11-08 11:02 ` Sudip Mukherjee
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.