Skip to content

Conversation

@dkouba-atym
Copy link
Contributor

While working with WAMR on Zephyr, I discovered that the sizes of a couple socket enums were not consistent between the host and inside of WASM. This resulted in an inability to create a UDP socket, as the layout of the enum was compressed (enums became 1 byte instead of 4) and the offset of hints_enabled was incorrect, and therefore all sockets created were TCP.

In WASM: sizes: enum=4, hints_t=12, off(type)=0 off(family)=4 off(en)=8
In Zephyr host: sizes: enum=1, hints_t=3, off(type)=0 off(family)=1 off(en)=2

As a result I've enforced the struct sizes using the same method it was done for a different enum and added the appropriate assertions to validate.

@lum1n0us
Copy link
Collaborator

I believe we should synchronize this modification with core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h.

@lum1n0us lum1n0us added the bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs. label Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Determine if this PR addresses a bug. It will be used by scripts to classify PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants