-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix mismatched expectations on index retrieval in Ember cluster lookup #12750
Conversation
AttributePathExpandIterator uses emberAfClusterIndex to look up the index of a cluster within a given endpoint. This in turn calls into emberAfFindClusterInTypeWithMfgCode to find that index. This returns an index that indexes into all clusters in that endpoint regardless of type. Later on however, it uses emberAfGetNthClusterId to retrieve the actual cluster index for a given index. However, this function applies the index as though it's indexing into a list of clusters that match the masking criteria (i.e server or client). This results in it retrieving the wrong cluster in cases where there is a mix of client and server clusters on a given endpoint. Since most places use this 'scoped index', this PR fixes emberAfFindClusterInTypeWithMfgCode to return a scoped index instead. Problem: Marc noted that when reading the WifiDiagnostics cluster, that on the server, the logs indicated a retrieval of a ClusterId 0x36, but the subsequent logs in the reporting engine seemed to indicate it was picking up ClusterId 0x37 oddly enough. Testing: Validated that the above bug no longer happens, as well as reading out the entire device using wildcards in the REPL to ensure everything still works.
I was puzzled why such a 'index-shifting-bug' would not have resulted in large, obvious failures since the data returned would have been for a different cluster than what was requested. This is especially true since in the large list of clusters in However, we have a variety of Read tests in both YAML and Python to cover this. So why didn't they break?
in AttributePathExpandIterator.cpp:125
Filed #12752 to at least handle some of those cases. |
Wild, thanks for digging into it! |
PR #12750: Size comparison from e4f3246 to 6f42abd Increases (18 builds for esp32, k32w, linux, nrfconnect, p6, qpg, telink)
Full report (29 builds for esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
AttributePathExpandIterator
usesemberAfClusterIndex
to look up the index of a cluster within a given endpoint. This in turn calls intoemberAfFindClusterInTypeWithMfgCode
to find that index. This returns an index that indexes into all clusters in that endpoint regardless of type.Later on however, it uses
emberAfGetNthClusterId
to retrieve the cluster ID for a given index. However, this function applies the index as though it's indexing into a list of clusters that match the masking criteria (i.e server or client). This results in it retrieving the wrong cluster in cases where there is a mix of client and server clusters on a given endpoint.Since most places use this 'scoped index', this PR fixes
emberAfFindClusterInTypeWithMfgCode
to return a scoped index instead.Problem:
Marc noted that when reading the WifiDiagnostics cluster, that on the
server, the logs indicated a retrieval of a ClusterId 0x36, but the
subsequent logs in the reporting engine seemed to indicate it was
picking up ClusterId 0x37 oddly enough.
Testing:
Validated that the above bug no longer happens, as well as reading out
the entire device using wildcards in the REPL to ensure everything still
works.