All of lore.kernel.org
 help / color / mirror / Atom feed
* [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; 4+ 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] 4+ 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; 4+ 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] 4+ 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; 4+ 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] 4+ 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
  0 siblings, 0 replies; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2026-06-16 20:48 UTC | newest]

Thread overview: 4+ 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

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.