[vlc-devel] [PATCH 1/2] compat: Workaround sendmsg bug on some ArmV8 Android devices
remi at remlab.net
Fri Mar 29 14:08:22 CET 2019
Overriding errno on success looks like a bad idea. It wouldn't be the first time that it breaks error handling in nonobvious manner.
And FWIW, I don't agree with the assessment that bugs in libc syscall wrappers cannot be coded around - especially if you target only one specific ISA.
Le 29 mars 2019 15:02:28 GMT+02:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>On some devices (at least up to Android 6) sendmsg will return its
>code on 32bits instead of 64.
>Most likely some code is storing the ssize_t on a size_t, getting rid
>the sign bit and therefore of the sign extension afterward.
>This causes us to use 0xFFFFFFFF as a very large number of bytes
>of an error.
>This patch works around the issue and assumes that 0xFFFFFFFF with a
>0 errno is an error and forces it to be returned on 64bits.
> include/vlc_network.h | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>diff --git a/include/vlc_network.h b/include/vlc_network.h
>index 7cc384587a..477d351cc8 100644
>@@ -280,6 +280,29 @@ static inline int net_GetPeerAddress( int fd, char
>*address, int *port )
> VLC_API char *vlc_getProxyUrl(const char *);
>+#if defined(__ANDROID__) && defined(__aarch64__)
>+ * Since we bumped the NDK version from 14 to 18, some devices (at
>least up to
>+ * Android 6) are returning errors on 4 bytes, even though ssize_t is
>+ * 8 bytes. This causes `value < 0` checks to yield false, and
>consider the value
>+ * as a non error.
>+ * As the patch lies in either the NDK or the Android kernel, or the
>+ * we can only work around it. If errno is not 0 & we receive -1, on
>+ * 64bits, we assume an error was returned.
>+static inline ssize_t vlc_sendmsg(int fd, const struct msghdr *msg,
>+ errno = 0;
>+ ssize_t ret = sendmsg(fd, msg, flags);
>+ if ((ret < 0 || ret == 0xFFFFFFFF) && errno != 0)
>+ return -1;
>+ return ret;
>+#define sendmsg(a, b, c) vlc_sendmsg(a,b,c)
> # ifdef __cplusplus
> # endif
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vlc-devel