Skip to content

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

Open
Listed in
@praveen-pk

Description

@praveen-pk

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?

Activity

niluxv

niluxv commented on Oct 25, 2022

@niluxv
Contributor

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

workingjubilee commented on Mar 6, 2023

@workingjubilee
Member

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

git-bruh

git-bruh commented on Mar 6, 2024

@git-bruh

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

niluxv commented on Mar 7, 2024

@niluxv
Contributor

My bad, I looked at the generic source 😞

niluxv

niluxv commented on Mar 7, 2024

@niluxv
Contributor

So I suppose this issue can be closed then?

Amanieu

Amanieu commented on Mar 15, 2024

@Amanieu
Member

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.

added this to the 1.0 milestone on Aug 12, 2024
added
E-mediumE-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate.
and removed on Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugE-mediumE-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate.O-gnubreakage-candidate

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Amanieu@praveen-pk@tgross35@niluxv@workingjubilee

        Issue actions

          msghdr.msg_iovlen is inconsistently declared in gnu and musl · Issue #2971 · rust-lang/libc