From: Eli Zaretskii <eliz@gnu.org>
To: YuPeng <yupeng@kylinos.cn>
Cc: gdb-patches@sourceware.org, tromey@sourceware.org,debianyu@163.com
Subject: Re: [PATCH] Fix use-after-free when Python Breakpoint.stop method deletes the breakpoint
Date: Wed, 18 Nov 2026 16:26:23 +0200 [thread overview]
Message-ID: <86h5hemd0w.fsf@gnu.org> (raw)
In-Reply-To: <1794998055185602167.295606@kylinos.cn> (message from YuPeng on Wed, 18 Nov 2026 18:34:15 +0800)
> From: YuPeng <yupeng@kylinos.cn>
> Cc: tromey@sourceware.org,debianyu@163.com
> Date: Wed, 18 Nov 2026 18:34:15 +0800
>
> If a Python Breakpoint.stop method calls self.delete(), the underlying
> breakpoint is freed while bpstat is still processing it.
>
> delete_breakpoint tries to clear references with
> bpstat_remove_bp_location, but that only walks
> thread->control.stop_bpstat, which still points at the bpstat chain from
> the previous stop (it is cleared in proceed()), not the chain currently
> being built by bpstat_stop_status. The current chain therefore keeps a
> dangling breakpoint pointer, and gdb crashes on the next access.
>
> The reproducer from the bug report returns False from stop(), so the
> crash happens right after the callback while infrun examines the bpstat
> chain (the report shows bpstat_explains_signal).
>
> Fix:
> - Assign thread->control.stop_bpstat = bs_head before the check_status
> loop in bpstat_stop_status, so bpstat_remove_bp_location can find and
> nullify the reference in the chain being processed.
> - In bpstat_check_breakpoint_conditions, return early if
> bs->breakpoint_at became NULL after the extension language callback.
> - In bpstat_stop_status, re-read b = bs->breakpoint_at after
> bpstat_check_breakpoint_conditions and skip the entry if it is NULL.
>
> Tested on x86_64-linux with an ASan build: without the fix gdb aborts
> with a heap-use-after-free; with it the breakpoint is deleted and the
> inferior exits normally.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34379
>
> I do not have an FSF copyright assignment on file; please let me know
> if you think this change needs one.
Thanks, but could you tell if the patch and the description were
generated by LLM, by any chance?
next prev parent reply other threads:[~2026-11-18 14:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 10:34 YuPeng
2026-11-18 14:26 ` Eli Zaretskii [this message]
2026-11-19 16:22 ` Andrew Burgess
2026-11-24 2:54 ` [PATCH v2] " YuPeng
2026-11-24 11:26 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86h5hemd0w.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=debianyu@163.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@sourceware.org \
--cc=yupeng@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox