NetBSD Problem Report #58216

From rhialto@falu.nl  Tue Apr 30 12:53:29 2024
Return-Path: <rhialto@falu.nl>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C5D181A9238
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 30 Apr 2024 12:53:29 +0000 (UTC)
Message-Id: <ZjDpwSPpRwO-X8UR@falu.nl>
Date: Tue, 30 Apr 2024 14:53:21 +0200
From: Rhialto <rhialto@falu.nl>
Reply-To: Rhialto <rhialto@falu.nl>
To: gnats-bugs@NetBSD.org
Subject: gdb breakpoints do not always work
X-Send-Pr-Version: 3.95

>Number:         58216
>Category:       bin
>Synopsis:       gdb breakpoints do not always work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 30 12:55:00 +0000 2024
>Last-Modified:  Tue Apr 30 18:10:01 +0000 2024
>Originator:     Rhialto
>Release:        NetBSD 10.0
>Organization:
>Environment:
System: NetBSD murthe.falu.nl 10.0 NetBSD 10.0 (GENERIC) #0: Thu Mar 28 08:33:33 UTC 2024 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	I'm not actually sure if this is a bug in gdb (category bin)
	or in the kernel (port-amd64 in that case).

	I have another PR open with a problem in the X server.
	I tried to gain more insights by attaching gdb to the X server
	process, and setting breakpoints on some key functions, such as
	glamor_get_vbo_space and glamor_text. However the breakpoints
	never triggered.            

	On further inspection, the breakpoints were marked as <PENDING> and
	therefore not functional.

	For some other symbols, it doesn't even pretend to set a breakpoint
	and errors out as soon as you try to continue the program.

	Hardware breakpoints (hbreak) do break, but then gdb has an
	assertion failure and exists soon after.

>How-To-Repeat:
	(on an ssh connection into the machine)
	(find out the pid of X, it is 28256 in this case)
	$ sudo gdb -p 28256
	GNU gdb (GDB) 11.0.50.20200914-git
	...
	(gdb) break glamor_get_vbo_space
	Breakpoint 1 at 0x6fb07d40d395: file /usr/xsrc/external/mit/xorg-server/dist/glamor/glamor_vbo.c, line 47.
	(gdb) break glamor_text
	Breakpoint 2 at 0x6fb07d41339e: file /usr/xsrc/external/mit/xorg-server/dist/glamor/glamor_text.c, line 97.
	(gdb) c
	Continuing.

	(trigger a signal to the X server by disconnecting a client)
	(I had set breakpoints on mmap and poll in the mean time,
	to check if breakpoints work at all)

	Thread 5 received signal SIGPIPE, Broken pipe.
	0x00006fb084246fea in poll () from /usr/lib/libc.so.12
	(gdb) info break
	Num     Type           Disp Enb Address            What
	1       breakpoint     keep y   <PENDING>          glamor_get_vbo_space
	2       breakpoint     keep y   <PENDING>          glamor_text
	3       breakpoint     keep y   <MULTIPLE>
	3.1                         y   <PENDING>          mmap
	3.2                         y   <PENDING>          mmap
	4       breakpoint     keep y   <MULTIPLE>
	4.1                         y   <PENDING>          poll
	4.2                         y   <PENDING>          poll
	(gdb) break InputThreadDoWork
	Breakpoint 5 at 0xdcbb0722
	(gdb) c
	Continuing.
	Warning:
	Cannot insert breakpoint 5.
	Cannot access memory at address 0xdcbb0722

	Command aborted.
	(gdb) c
	Continuing.
	Warning:
	Cannot insert breakpoint 5.
	Cannot access memory at address 0xdcbb0722

	Command aborted.
	(gdb) disa 5
	(gdb) hbreak glamor_text
	Hardware assisted breakpoint 6 at 0x6fb07d41339e: file /usr/xsrc/external/mit/xorg-server/dist/glamor/glamor_text.c, line 97.
	(gdb) c
	Continuing.
	[Switching to LWP 28256 of process 28256]

	Thread 4 "" hit Breakpoint 6, glamor_text (
	    drawable=drawable@entry=0x6fb0824c98c0, gc=gc@entry=0x6fb082103ac0,
	    glamor_font=glamor_font@entry=0x6fb086e3bfb0,
	    prog=prog@entry=0x6fb088f24268, x=x@entry=17, y=y@entry=377,
	    count=count@entry=6,
	    s_chars=s_chars@entry=0x6fb086f52940 "        L\006\006",
	    charinfo=charinfo@entry=0x7f7fffd18400, sixteen=sixteen@entry=0)
	    at /usr/xsrc/external/mit/xorg-server/dist/glamor/glamor_text.c:97
	97      {
	(gdb) bt
	#0  glamor_text (drawable=drawable@entry=0x6fb0824c98c0,
	    gc=gc@entry=0x6fb082103ac0, glamor_font=glamor_font@entry=0x6fb086e3bfb0,
	    prog=prog@entry=0x6fb088f24268, x=x@entry=17, y=y@entry=377,
	    count=count@entry=6,
	    s_chars=s_chars@entry=0x6fb086f52940 "        L\006\006",
	    charinfo=charinfo@entry=0x7f7fffd18400, sixteen=sixteen@entry=0)
	    at /usr/xsrc/external/mit/xorg-server/dist/glamor/glamor_text.c:97
	#1  0x00006fb07d413e28 in glamor_image_text (
	    drawable=drawable@entry=0x6fb0824c98c0, gc=gc@entry=0x6fb082103ac0,
	    x=x@entry=17, y=y@entry=377, count=count@entry=6,
	    chars=chars@entry=0x6fb086f52940 "        L\006\006",
	    sixteen=sixteen@entry=0)
	    at /usr/xsrc/external/mit/xorg-server/dist/glamor/glamor_text.c:467
	#2  0x00006fb07d413fa9 in glamor_image_text8 (drawable=0x6fb0824c98c0,
	    gc=0x6fb082103ac0, x=17, y=377, count=6,
	    chars=0x6fb086f52940 "        L\006\006")
	    at /usr/xsrc/external/mit/xorg-server/dist/glamor/glamor_text.c:480
	#3  0x00000000dcb5fbbe in damageImageText8 ()
	#4  0x00000000dca7e6b5 in doImageText ()
	#5  0x00000000dca7f8df in ImageText ()
	#6  0x00000000dca8395b in ProcImageText8 ()
	#7  0x00000000dca85c2e in Dispatch ()
	#8  0x00000000dca55e1f in dix_main ()
	#9  0x00000000dca559cd in ___start ()
	#10 0x00007f7ee6e0baf8 in ?? () from /usr/libexec/ld.elf_so
	#11 0x0000000000000005 in ?? ()
	#12 0x00007f7fffd19480 in ?? ()
	#13 0x00007f7fffd19491 in ?? ()
	#14 0x00007f7fffd19494 in ?? ()
	#15 0x00007f7fffd19499 in ?? ()
	#16 0x00007f7fffd1949f in ?? ()
	#17 0x0000000000000000 in ?? ()
	(gdb) next
	[New process 28256]
	/usr/src/external/gpl3/gdb/lib/libgdb/../../dist/gdb/infrun.c:5683: internal-error: int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed.
	A problem internal to GDB has been detected,
	further debugging may prove unreliable.
	Quit this debugging session? (y or n) y

	This is a bug, please report it.  For instructions, see:
	<https://www.gnu.org/software/gdb/bugs/>.

	/usr/src/external/gpl3/gdb/lib/libgdb/../../dist/gdb/infrun.c:5683: internal-error: int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed.
	A problem internal to GDB has been detected,
	further debugging may prove unreliable.
	Unable to dump core, use `ulimit -c unlimited' before executing GDB next time.
	[ 108164.2883624] sorry, pid 28256 was killed: orphaned traced process
	You have mail in /var/mail/rhialto
	murthe.0:~$

>Fix:
	unknown.

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert                            <rhialto/at/falu.nl>
\X/ There is no AI. There is just someone else's work.           --I. Rose

>Audit-Trail:
From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: bin/58216: gdb breakpoints do not always work
Date: Tue, 30 Apr 2024 12:50:22 -0400

 Does setting security.pax.mprotect.ptrace appropriately work?

 christos


From: Rhialto <rhialto@falu.nl>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
	Rhialto <rhialto@falu.nl>
Subject: Re: bin/58216: gdb breakpoints do not always work
Date: Tue, 30 Apr 2024 20:05:40 +0200

 Yes and no.

 I set security.pax.mprotect.ptrace=2 (thanks for the hint!).

 The breakpoint is hit, but the internal error still gets triggered (same
 as with the hardware breakpoint). 

 (gdb) break mmap
 Breakpoint 1 at 0x7311cd1795f2: mmap. (2 locations)
 (gdb) c
 Continuing.
 [Switching to LWP 1491 of process 1491]

 Thread 10 "" hit Breakpoint 1, _mmap (addr=addr@entry=0x0, len=8192,
     prot=prot@entry=3, flags=flags@entry=1, fd=13, offset=4512096256)
     at /usr/src/lib/libc/sys/mmap.c:59
 59      {
 (gdb) c
 Continuing.
 [New process 1491]
 /usr/src/external/gpl3/gdb/lib/libgdb/../../dist/gdb/infrun.c:5683: internal-error: int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n) n

 This is a bug, please report it.  For instructions, see:
 <https://www.gnu.org/software/gdb/bugs/>.

 /usr/src/external/gpl3/gdb/lib/libgdb/../../dist/gdb/infrun.c:5683: internal-error: int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Unable to dump core, use `ulimit -c unlimited' before executing GDB next time.
 Command aborted.
 (gdb) q
 A debugging session is active.

         Inferior 1 [process 1491] will be detached.

 Quit anyway? (y or n) y
 Detaching from program: /usr/X11R7-9.3/bin/X, process 1491
 [Inferior 1 (process 1491) detached]
 murthe.0:~$

 At this point, X is still terminated, even though it doesn't say so
 here.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.