Prevent Kingsmith X21 crash when BLE service UUID fallback is missing - #4547
Conversation
0fc2418 to
f261d35
Compare
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
@koichiro Hi did you check my comment? |
|
@cagnulein I checked the PR, but I can’t seem to find any comment on it. Could you point me to the comment you mean, or let me know where I should check? Thanks! |
|
Hi @koichiro sure this one #4547 (comment) |
You're right — if the goal is only to add support for the new X21 variant, I think it can be fixed with just a few lines. I made a broader change because I thought it was necessary for consistency, but I may have misunderstood the intended scope. Would you prefer that I revise it to keep the change minimal? |
|
I'm also worried about compatibility since we can't test back immediately the different setup. So that's why that I'm trying to keep the changes at minimal. So yes please |
f261d35 to
acd35d3
Compare
|
@cagnulein I’ve reworked the implementation to minimize the changes as much as possible and updated the PR accordingly. I also verified that the modified code works correctly on my setup. Please take another look when you have time. |
|
thanks! |
Summary
This fixes a segmentation fault that can happen when connecting some Kingsmith WalkingPad X21 variants.
On affected devices,
kingsmithr2treadmill::serviceScanDone()may fail to create a BLE service object for the first expected service UUID. The previous code then continued with a nullgattCommunicationChannelService, which led to an invalidQObject::connect(...)call and a crash.Root cause
Some Kingsmith X21 variants do not expose the same communication service UUID.
In the reported case, the device exposed:
00001234-0000-1000-8000-00805f9b34fbwhile the X21-specific path first expected UUIDs such as:
00021234-0000-1000-8000-00805f9b34fb00011234-0000-1000-8000-00805f9b34fbWhen no matching fallback was found,
createServiceObject(...)returnednullptr, and the code still tried to connect signals and calldiscoverDetails(), causing a segmentation fault.Changes
This patch updates the Kingsmith R2 treadmill connection setup to:
Effect
This should prevent crashes when powering on or connecting certain Kingsmith WalkingPad X21 devices, including cases where the treadmill uses
00001234instead of the previously assumed service UUID layout.Reproduction
Observed on:
Crash sequence from the log was:
KS_NACH_X21C default service id not foundQObject::connect(...): invalid nullptr parameterNotes
This change is intentionally defensive: even if an unsupported UUID layout is encountered, the app now fails gracefully instead of dereferencing a null BLE service pointer.
Before log (SEGV)
After log