Skip to content
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

Not call onError in BufferedReadCallback #30965

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yunhanw-google
Copy link
Contributor

If onError has been called from BufferedReadCallback when processing multiple attrbitues, potentially onError or onAttribute or onEvent could be called again from ReadClient, as a result, the behavior in application could be unexpected, crash is possible. onError should be called only with close path from readClient.

@github-actions github-actions bot added the app label Dec 12, 2023
mCallback.OnError(err);
ChipLogError(DataManagment, "Fail to dispatch buffered data with error %s in path %s", err.toString(), mBufferedPath.LogPath())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this the right thing? Under what conditions does DispatchBufferedData fail, and in those cases should we in fact press on, or should we in fact error out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the error condition,
Looking at the DispatchBufferedData, further GenerateListTLV, it could fail to calloc with buffer and other error inside GenerateListTLV.

If OnReportBegin and OnReportEnd fails, we need Error out in readClient since these error could be fatal one, not worth moving on, maybe we should change API shape for onReportBegin and onReportEnd from
void OnReportBegin() override;
void OnReportEnd() override;
to
CHIP_ERROR OnReportBegin() override;
CHIP_ERROR OnReportEnd() override;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to simulate such cases in a unit test?

It seems a bit uncomfortable to create a change deep inside our core stack without a corresponding test that shows "this was bad before, it is good now".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yunhanw-google We could set a flag in the buffered read callback that returns error for the next call from ReadClient, if we just want to treat these as completely fatal errors....

That is, keep doing OnError, but after that respond to all calls from the readclient with errors and not notify our consumer anymore.

@yunhanw-google yunhanw-google marked this pull request as draft January 31, 2024 21:58
Copy link

stale bot commented Apr 22, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label Apr 22, 2024
@bzbarsky-apple bzbarsky-apple removed the stale Stale issue or PR label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants