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

Fix Complex error size #403

Merged
merged 3 commits into from
Jun 29, 2023
Merged

Fix Complex error size #403

merged 3 commits into from
Jun 29, 2023

Conversation

mkeeter
Copy link
Contributor

@mkeeter mkeeter commented Jun 29, 2023

Idol calls returning a Complex error type return a non-zero error code of 1, but also serialize their error into the buffer provided by the caller. Right now, we're not necessarily sizing that buffer correctly when making HIF and RPC calls! If the ok type is smaller than the error type, then the buffer will be undersized and bytes will be dropped on the floor during the sys_reply call.

sys_reply does not report errors, but it expects the server to check the buffer size itself. A separate issue in Idol (oxidecomputer/idolatry#36) means that the generated server code makes the same mistake in checking the buffer size; otherwise, we would have seen this error much sooner!

(Luckily, this all works correctly in task-to-task calls, because Idol's generated client API correctly computes the maximum REPLY_SIZE and passes correctly-sized buffers)

This PR correctly computes the reply_size() for Idol operations using Complex error types. It also fixes an error in computing serialized size for enum types (we were taking the sum of variant sizes instead of the max, which is wrong).

@mkeeter mkeeter enabled auto-merge (squash) June 29, 2023 18:29
@mkeeter mkeeter merged commit 47d3d20 into master Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants