Bug 391367

Summary: KIO 5.43: FTBFS with musl libc on 64-bit platforms
Product: [Frameworks and Libraries] frameworks-kio Reporter: A. Wilcox (awilfox) <awilfox>
Component: generalAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: normal CC: kdelibs-bugs, simonandric5
Priority: NOR    
Version: 5.43.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description A. Wilcox (awilfox) 2018-03-04 04:46:31 UTC
musl is strictly POSIX conformant, which means it uses int for msg_iovlen and socklen_t for msg_controllen in the msghdr struct.  (See http://git.musl-libc.org/cgit/musl/commit/arch/x86_64/bits/socket.h?id=7168790763cdeb794df52be6e3b39fbb021c5a64 for more information.)

POSIX defines msghdr as containing "at least" the standard members.  (See http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/socket.h.html for citation.)

Since the new shared fd code in KIO (non-conformantly) assumes the members and layout of msghdr in its ctor, it FTBFS on 64-bit musl platforms (including x86_64, ppc64, aarch64):

In file included from /usr/src/packages/user/kio/src/kio-5.43.0/src/ioslaves/file/fdreceiver.cpp:23:0:
/usr/src/packages/user/kio/src/kio-5.43.0/src/ioslaves/file/sharefd_p.h: In constructor 'FDMessageHeader::FDMessageHeader()':
/usr/src/packages/user/kio/src/kio-5.43.0/src/ioslaves/file/sharefd_p.h:78:37: error: invalid conversion from 'char (*)[24]' to 'int' [-fpermissive]
         , msg{nullptr, 0,  &io, 1,  &cmsg_buf, sizeof cmsg_buf, 0}
                                     ^~~~~~~~~
/usr/src/packages/user/kio/src/kio-5.43.0/src/ioslaves/file/sharefd_p.h:78:55: error: invalid conversion from 'long unsigned int' to 'void*' [-fpermissive]
         , msg{nullptr, 0,  &io, 1,  &cmsg_buf, sizeof cmsg_buf, 0}
                                                       ^~~~~~~~
/usr/src/packages/user/kio/src/kio-5.43.0/src/ioslaves/file/sharefd_p.h:78:66: warning: missing initializer for member 'msghdr::__pad2' [-Wmissing-field-initializers]
         , msg{nullptr, 0,  &io, 1,  &cmsg_buf, sizeof cmsg_buf, 0}
                                                                  ^
/usr/src/packages/user/kio/src/kio-5.43.0/src/ioslaves/file/sharefd_p.h:78:66: warning: missing initializer for member 'msghdr::msg_flags' [-Wmissing-field-initializers]
Comment 1 Chinmoy Ranjan Pradhan 2018-03-04 10:57:05 UTC
Git commit 2a2a8a0fe5ab882482784c90b217770266b460f4 by Chinmoy Ranjan Pradhan.
Committed on 04/03/2018 at 10:56.
Pushed by chinmoyr into branch 'master'.

Do not assume layout of msghdr and iovec structure

Summary:
Class FDMessageHeader assumes the layout of msghdr and iovec structure in its constructor. However, this assumption is wrong
because as per POSIX standards both may contain more members than usual. This patch fixes the issue.

Reviewers: dfaure, awilcox

Subscribers: #frameworks

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D11011

M  +9    -2    src/ioslaves/file/sharefd_p.h

https://commits.kde.org/kio/2a2a8a0fe5ab882482784c90b217770266b460f4