Skip to content

Fix WASI struct sizes #1245

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

Merged
merged 1 commit into from
Apr 29, 2020
Merged

Fix WASI struct sizes #1245

merged 1 commit into from
Apr 29, 2020

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Apr 29, 2020

fixes #1116 if it turns out that the new assumptions made there are correct. Also see the linked WASI issue.

@MaxGraey
Copy link
Member

MaxGraey commented Apr 29, 2020

@dcodeIO I'm wondering what if introduce @alignas decorator for such cases?

@unmanaged @alignas(48)
export abstract class event {
   /** User-provided value that got attached to `subscription#userdata`. */
  userdata: userdata;
  /** If non-zero, an error that occurred while processing the subscription request. */
  error: errno;
  /** The type of the event that occurred. */
  type: eventtype;
}

wdyt?

@dcodeIO
Copy link
Member Author

dcodeIO commented Apr 29, 2020

Seems useful in certain use cases, but might also have some strange edge cases here. For example, what do we do if an extension of the class doesn't fit into the base class's alignment? Do we silently double the size, or should there be an error. Also we'd probably still have some __padding fields, for example when modeling unions or variable-size fields, i.e. usize.

@MaxGraey
Copy link
Member

MaxGraey commented Apr 29, 2020

C++ for example just ignore alignment with less value than in base class for derived classes:
https://repl.it/repls/IdealEnlightenedZettabyte

@dcodeIO dcodeIO merged commit 70e1578 into master Apr 29, 2020
@dcodeIO dcodeIO deleted the wasi-struct-sizes branch May 14, 2020 21:12
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.

WASI: Invalid clock event structure size
2 participants