-
Notifications
You must be signed in to change notification settings - Fork 218
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
[dbus] fix Scan
crashing
#1814
[dbus] fix Scan
crashing
#1814
Conversation
5cc6fb5
to
058e1a5
Compare
Finally got around to addressing the feedback (sorry for the delay). Please let me know if either of you would like additional changes. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@bukepo, would you have time to give this another look? 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍🏼
@jdswensen , if you would like to keep the commits separate after merge, can you add the PR number to the commit header? For example:
Alternatively, I can squash-merge and GitHub will automatically add the PR number to the commit header. Let me know what you prefer. Thanks! |
Avoid crashes when the compiler does not automatically initialize the scan results to zero. This behavior was not expressing itself on x86_64 platforms, but did cause crashes on an ARM Cortex-A7.
The dbus encoding and decoding methods were attempting to send the incorrect amount of data over dbus. This breaks the dbus introspect contract and causes runtime errors. To fix the issue: - Re-introduce the entire `ActiveScanResult` data structure to the introspect document. - Coerce the RSSI value into an int16 when encoding and decoding an `ActiveScanResult`.
058e1a5
to
80da81d
Compare
@jwhui, commits have been updated and PR has been rebased onto the latest. |
Avoid crashes when the compiler does not automatically initialize the scan results to zero. This behavior was not expressing itself on x86_64 platforms, but did cause crashes on an ARM Cortex-A7.
I ran into an issue while trying to use the
dbus
Scan
API. For my platform (imx6ull, built with yocto), I was able to repeatably causeotbr
to error by running:Callstack:
There are three intertwined problems with the current
dbus
Scan
APIActiveScanResult
is uninitialized when forming a reply message.When cross-compiling for a Cortex-A7 platform, the boolean values were not being set causing the uninitialized values to be used during message encoding. This resulted in the boolean values being invalid data and causing
dbus
error messages when attempting to send the message.arguments to dbus_message_iter_append_basic() were incorrect, assertion "*bool_p == 0 || *bool_p == 1"
I tested the same thing on my
x86_64
host machine at one point, but it appears that the compiler chose to initialize the values to zero, so there were no issues.The introspect contract and the scan reply message do not match.
The introspect document lists five variables, but the actual return has 12 variables. For example, after fixing the boolean return:
However, the definition in the introspect is:
I have assumed that the introspect document is the source of truth and removed the excess data from both the encoding step and the data structure itself. The data is not present (XPAN is 0), so it looks like it isn't being populated by anything anyway.
The introspect contract data types do not match the data being extracted from the data structure.
For example, the
rssi
is an 8-bit value in theActiveScanResult
data structure, but it is a 16-bit value in thedbus
return definition. This causesdbus
to error with:Array or variant type requires that type uint16 be written, but byte was written
Given that the older definitions (
channel
,rssi
) were correct, I chose to fix this by reverting the definitions in the introspect document.Please let me know if anything needs to be changed!