-
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 src/lib/support/StateMachine pattern matching #13664
Fix src/lib/support/StateMachine pattern matching #13664
Conversation
PR #13664: Size comparison from 78a6636 to 3693b83 Full report (14 builds for efr32, k32w, linux, p6, qpg, telink)
|
3693b83
to
5facee3
Compare
PR #13664: Size comparison from 78a6636 to 5facee3 Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
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.
Good catch.
03232f1
to
5facee3
Compare
PR #13664: Size comparison from 150c479 to 5facee3 Full report (6 builds for k32w, qpg, telink)
|
5facee3
to
3690bb6
Compare
PR #13664: Size comparison from 150c479 to 3690bb6 Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
PR #13664: Size comparison from 41d3a6c to b07ee40 Full report (14 builds for efr32, k32w, linux, p6, qpg, telink)
|
The Enter method can rewrite the state objects during pattern matching traversal. We need a one-shot bool to ensure we only execute Enter once. And although state changes from Exit, LogTransition and GetName aren't expected, we should check in these too. In all cases, the pattern match should only execute once. This commit adds the necessary check and a test case to verify this is working correctly.
b07ee40
to
5f459ad
Compare
PR #13664: Size comparison from 5274676 to 5f459ad Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
fast track: small delta with unit tests, created by a domain owner. |
The Enter method can rewrite the state objects during pattern matching traversal. We need a one-shot bool to ensure we only execute Enter once. And although state changes from Exit, LogTransition and GetName aren't expected, we should check in these too. In all cases, the pattern match should only execute once. This commit adds the necessary check and a test case to verify this is working correctly.
Problem
The variant state Enter method can rewrite state objects during pattern matching traversal if Dispatch is called and a state transition occurs. We therefore need to ensure that the Enter method pattern matching can only evaluate true once. Without a check for this, the pattern matching may continue accessing the state object after its destructor has been called.
Change overview
Add a one-shot bool to ensure that Enter is only executed once. And although state changes from Exit, LogTransition and GetName aren't expected, checks are added for these too. In all cases, the pattern match should only execute once.
Testing
A new unit test has been added to check for the bug that is fixed by this PR.