From: Pauli Virtanen <noreply@github.com>
To: linux-bluetooth@vger.kernel.org
Subject: [bluez/bluez] 3e7f7a: shared: mainloop: Skip removed mainloop events
Date: Sun, 27 Sep 2026 13:11:06 -0700 [thread overview]
Message-ID: <bluez/bluez/push/refs/heads/1174578/000000-8178da@github.com> (raw)
Branch: refs/heads/1174578
Home: https://github.com/bluez/bluez
Commit: 3e7f7a4d265fa3e7ef3f9224cd3acb9c22491f9b
https://github.com/bluez/bluez/commit/3e7f7a4d265fa3e7ef3f9224cd3acb9c22491f9b
Author: Pauli Virtanen <pav@iki.fi>
Date: 2026-09-27 (Sun, 27 Sep 2026)
Changed paths:
M src/shared/mainloop.c
Log Message:
-----------
shared: mainloop: Skip removed mainloop events
mainloop_remove_fd() on an fd that occurs in the same epoll_wait batch
as the current callback, causes ASan crash.
Several callsites do this, crash is sporadic since it requires suitable
timing.
Fix by adding registration ID in each event and dispatching only if that
registration is still active.
Fixes random btvirt crashes.
Log:
ERROR: AddressSanitizer: heap-use-after-free on address 0x7b7576be3f18
READ of size 8 at 0x7b7576be3f18 thread T0
#0 0x5637f7b4014f in mainloop_run src/shared/mainloop.c:104
#1 0x5637f7b41f79 in mainloop_run_with_signal src/shared/mainloop-notify.c:196
#2 0x5637f7aa598b in main emulator/main.c:310
freed by thread T0 here:
#0 0x7f45788ee4cf in free.part.0 (/lib64/libasan.so.8+0xee4cf)
#1 0x5637f7b40d05 in mainloop_remove_fd src/shared/mainloop.c:213
previously allocated by thread T0 here:
#0 0x7f45788ef24f in calloc (/lib64/libasan.so.8+0xef24f)
#1 0x5637f7b4034b in mainloop_add_fd src/shared/mainloop.c:142
Assisted-by: opencode:gpt-6-sol
Commit: 8178da05c017372532ee7ca1d47891bd747728e8
https://github.com/bluez/bluez/commit/8178da05c017372532ee7ca1d47891bd747728e8
Author: Pauli Virtanen <pav@iki.fi>
Date: 2026-09-27 (Sun, 27 Sep 2026)
Changed paths:
M .gitignore
M Makefile.am
A unit/test-mainloop.c
Log Message:
-----------
unit: test-mainloop: add basic mainloop test
Exercise basic mainloop fd add / remove / modify and timeouts.
src/shared/tester.h depends on mainloop and cannot be used here, so
write tests without the framework.
Add tests:
Test Modify File Descriptor
Test Re-Add Other Callback
Test Timeout
Assisted-by: opencode:gpt-6-sol
Compare: https://github.com/bluez/bluez/compare/3e7f7a4d265f%5E...8178da05c017
To unsubscribe from these emails, change your notification settings at https://github.com/bluez/bluez/settings/notifications
reply other threads:[~2026-09-27 20:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=bluez/bluez/push/refs/heads/1174578/000000-8178da@github.com \
--to=noreply@github.com \
--cc=linux-bluetooth@vger.kernel.org \
/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