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

msghdr.msg_iovlen is inconsistently declared in gnu and musl #2971

Open
Tracked by #3248
praveen-pk opened this issue Oct 20, 2022 · 6 comments
Open
Tracked by #3248

msghdr.msg_iovlen is inconsistently declared in gnu and musl #2971

praveen-pk opened this issue Oct 20, 2022 · 6 comments
Labels
breakage-candidate C-bug Category: bug E-medium E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. O-gnu
Milestone

Comments

@praveen-pk
Copy link

While using socket API in cloud-hypervisor project, I noticed an inconsistency with msghdr struct between gnu and musl targets.

In gnu
msghdr.msg_iovlen is declared as size_t

pub msg_iovlen: ::size_t,

In musl
msghdr.msg_iovlen is declared as c_int

pub msg_iovlen: ::c_int,

cloud-hypervisor/cloud-hypervisor#4642 (comment) describes the error I encountered due to this inconsistency.

Is this expected? If not, could you please fix it?

@niluxv
Copy link
Contributor

niluxv commented Oct 25, 2022

Hm, glibc seems to declare it as an integer too, see the glibc header source.
(The musl one is correct, see the musl header source.)

But changing it would be a breaking change I guess...

@workingjubilee
Copy link
Member

The glibc type should be corrected to match the glibc definition, we can consider this for 0.3

@git-bruh
Copy link

git-bruh commented Mar 6, 2024

The current declaration seems to be correct, the linux-specific socket.h header in glibc declares it as size_t: https://github.com/bminor/glibc/blob/b6e3898194bbae78910bbe9cd086937014961e45/sysdeps/unix/sysv/linux/bits/socket.h#L269

@niluxv
Copy link
Contributor

niluxv commented Mar 7, 2024

My bad, I looked at the generic source 😞

@niluxv
Copy link
Contributor

niluxv commented Mar 7, 2024

So I suppose this issue can be closed then?

@Amanieu
Copy link
Member

Amanieu commented Mar 15, 2024

See this musl commit for the background. Essentially, the glibc version matches the one used in the kernel. Musl uses a POSIX-ly correct variant, but then zero-fills the padding in the syscall wrapper before passing it on to the kernel.

It is hard to say what the correct approach is here.

@tgross35 tgross35 added this to the 1.0 milestone Aug 12, 2024
@tgross35 tgross35 added E-medium E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. and removed help wanted labels Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakage-candidate C-bug Category: bug E-medium E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. O-gnu
Projects
None yet
Development

No branches or pull requests

6 participants