-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bluetoothd crashes when discover_devices is terminated #9
Comments
Hi, the discover_devices example registers no SIGINT handler, so when you press CTRL+C the process is terminated immediately without cleanup. This should not matter as bluetoothd as an operating system service must handle the case of sudden process termination gracefully. If you change discover_devices like this https://gist.github.com/surban/788203c5d7211a5b2e3d92f68382ef3e it will indeed stop the discovery session:
Could you report this bug again against bluetoothd? Sebastian |
thanks for investigation |
# This is the 1st commit message: BLE Passive Scanning # This is the commit message #2: monitor # This is the commit message bluez#3: monitor # This is the commit message bluez#4: monitor # This is the commit message bluez#5: monitor # This is the commit message bluez#6: monitor # This is the commit message bluez#7: monitor # This is the commit message bluez#8: monitor # This is the commit message bluez#9: monitor # This is the commit message bluez#10: monitor # This is the commit message bluez#11: monitor # This is the commit message bluez#12: monitor # This is the commit message bluez#13: monitor # This is the commit message bluez#14: monitor # This is the commit message bluez#15: monitor # This is the commit message bluez#16: monitor # This is the commit message bluez#17: monitor # This is the commit message bluez#18: monitor # This is the commit message bluez#19: monitor # This is the commit message bluez#20: monitor # This is the commit message bluez#21: monitor # This is the commit message bluez#22: monitor # This is the commit message bluez#23: monitor # This is the commit message bluez#24: monitor # This is the commit message bluez#25: monitor # This is the commit message bluez#26: monitor # This is the commit message bluez#27: monitor # This is the commit message bluez#28: monitor # This is the commit message bluez#29: monitor # This is the commit message bluez#30: monitor # This is the commit message bluez#31: monitor # This is the commit message bluez#32: monitor # This is the commit message bluez#33: monitor # This is the commit message bluez#34: monitor # This is the commit message bluez#35: monitor # This is the commit message bluez#36: monitor # This is the commit message bluez#37: monitor # This is the commit message bluez#38: monitor # This is the commit message bluez#39: monitor # This is the commit message bluez#40: monitor # This is the commit message bluez#41: monitor # This is the commit message bluez#42: monitor # This is the commit message bluez#43: monitor # This is the commit message bluez#44: monitor # This is the commit message bluez#45: monitor # This is the commit message bluez#46: monitor # This is the commit message bluez#47: monitor # This is the commit message bluez#48: monitor # This is the commit message bluez#49: monitor # This is the commit message bluez#50: monitor # This is the commit message bluez#51: monitor # This is the commit message bluez#52: monitor # This is the commit message bluez#53: monitor # This is the commit message bluez#54: monitor # This is the commit message bluez#55: monitor # This is the commit message bluez#56: monitor # This is the commit message bluez#57: monitor # This is the commit message bluez#58: monitor # This is the commit message bluez#59: monitor # This is the commit message bluez#60: monitor # This is the commit message bluez#61: monitor # This is the commit message bluez#62: monitor
Which leads to a crash of bluetoothd at least on ARMv7 with versions 5.55 and 5.60:
free(): invalid next size (fast)
Limited testing on x86_64 shows no crash with 5.48, though the stop_fn never get's called as well.
Reason:
discover_devices() holds a SingleSessionToken while single_session() spawns a task waiting to receive something on the other end of the channel. AFAICT it won't ever receive something, so the stop_fn is never called which would stop the discovery and clean up.
How to reproduce:
run
RUST_LOG=trace ./discover_devices
and hit CTRL+C, notice a log missing "StopDiscovery" like:'''
[2021-08-11T12:47:23Z TRACE bluer::session] Connected to D-Bus with unique name :1.4321
[2021-08-11T12:47:23Z TRACE mio::poll] registering event source with poller: token=Token(0), interests=READABLE
[2021-08-11T12:47:23Z TRACE bluer::session] Starting event loop for :1.4321
Discovering devices using Bluetooth adapater hci0
[2021-08-11T12:47:23Z TRACE bluer::adapter] /org/bluez/hci0: org.bluez.Adapter1.Powered := true
[2021-08-11T12:47:23Z TRACE bluer::session] Starting new single session for /org/bluez/hci0
[2021-08-11T12:47:23Z TRACE bluer::adapter] /org/bluez/hci0: org.bluez.Adapter1.SetDiscoveryFilter ({"UUIDs": Variant([]), "Transport": Variant("auto"), "DuplicateData": Variant(false), "Discoverable": Variant(false)},)
[2021-08-11T12:47:23Z TRACE bluer::adapter] /org/bluez/hci0: org.bluez.Adapter1.SetDiscoveryFilter (...) -> Ok(())
[2021-08-11T12:47:23Z TRACE bluer::adapter] /org/bluez/hci0: org.bluez.Adapter1.StartDiscovery ()
[2021-08-11T12:47:23Z TRACE bluer::adapter] /org/bluez/hci0: org.bluez.Adapter1.StartDiscovery (...) -> Ok(())
[2021-08-11T12:47:23Z TRACE bluer::session] Adding event subscription for /org/bluez/hci0 with child_objects=true
[2021-08-11T12:47:23Z TRACE bluer::session] Event: PropertiesChanged { object: Path("/org/bluez/hci0\u{0}"), interface: "org.bluez.Adapter1", changed: {"Discovering": Variant(true)} }
...
^C
'''
If you modify the discover_devices example to drop the adapter earlier, then there's still no "StopDiscovery" in the log as expected
The text was updated successfully, but these errors were encountered: