-
Notifications
You must be signed in to change notification settings - Fork 165
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(libsinsp,test): remove undefined behavior in test event generation #969
Conversation
Signed-off-by: Luca Guerra <[email protected]>
Signed-off-by: Luca Guerra <[email protected]>
/milestone 0.11.0 |
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 @LucaGuerra also for sharing your debugging journey 😎
/approve
LGTM label has been added. Git tree hash: 8ffeba4dbdce13525512670d90b2de4d56476d85
|
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, incertum, LucaGuerra The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
/approve
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area libsinsp
/area tests
Does this PR require a change in the driver versions?
No.
What this PR does / why we need it:
This PR fixes a fun bug in the libsinsp test suite that is simply an instance of this: https://stackoverflow.com/questions/727663/why-does-this-variadic-function-fail-on-4th-parameter-on-windows-x64 .
Essentially, passing an integer literal to a variadic function and expecting a 64 bit value is undefined behavior, as the integer literal is type
int
and not the correct 64 bit size. We caught this on ARM64 after the 8th parameter due to that specific implementation and parameter passing via registers/stack but could happen anywhere.The fix is simply to either cast the integer or pass a variable, which is what happens in this PR. When I felt it right I added some descriptive variable names so tests can still be easy to read.
We will need another similar PR everywhere we call the event encoding function (I believe in the gVisor implementation).
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Merging this PR unblocks this: #962 .
Does this PR introduce a user-facing change?: