From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14857 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mathias Lang Newsgroups: gmane.linux.lib.musl.general Subject: [BUG] fseek behavior differs on whence parameter Date: Wed, 23 Oct 2019 14:48:21 +0900 Message-ID: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f3221005958d775c" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="155555"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-14873-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 23 11:35:34 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iND3F-000eKm-Td for gllmg-musl@m.gmane.org; Wed, 23 Oct 2019 11:35:34 +0200 Original-Received: (qmail 5566 invoked by uid 550); 23 Oct 2019 09:35:30 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 5130 invoked from network); 23 Oct 2019 05:48:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bpfkorea-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=YzVkRq897wxK0gJ5DL14VibxwQAIUSfRCe5HY2971EM=; b=KJZraWAbzdd+d3XMonzcZSVmTJOBOlunfNAtkZIgi6qZCGiNOOW/hxhoraqPOsrGgn Ah0daqCN3MwBkUOGF7JBVkBtcuhoUI+Zwbr7dOPwVW/oQ41cYKmPxhWGIIibPuVgl41V FTMZ8s5k4IIBgCExhngLLSRUt5oxOgG9lmHuiw6gerdXxlFI2Jw/4kZ/zhMhKBNTjMAQ g1+z7mtHj/GNJPUTG0+5qqfq1b19HTaQ7WeE8yWHLS5XodSQ5DHTnOc4n4/6XcO5f6Ct ctn9xn4O8CQoFr8x+jdviG7tTaMYXt5eMDXFJAJi+nofHYAwCyCFqTmwg25iB8gr/trt ZTDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YzVkRq897wxK0gJ5DL14VibxwQAIUSfRCe5HY2971EM=; b=ZP4oF6NmwKzGDrjjfRnDLphnLwN5ei/91Fr0dIpy6lt272e+KQJqoIz6N1hjPrDrpg SAwZT7/IFWDV4iMOC1ts7MUASl7y81FINq5br98kDJ/J7uGnLdUXEEZZqxAEuBxe6IB/ WLyxHx2J3XNriOv/sbRCiE0/iJDCW5Q/4n2Ga4drbWtfIesn/M2LuPelSR7PdU59W7YC xWwlyFebg6s6AS6NJmBpg3SrmxjrWdZTGOcfnusXW+Mf343MgH/8e5crNDo5Mxkl8sdw 147Kj2T4nPT1ixDwvo9IgDo6iz94FeFQeyT2OEvFleoWisuwn/E0WBwdHhnEvtJSJinC gUTg== X-Gm-Message-State: APjAAAVE2fEQOkYLeG/vuPk01jhspipiUQygv1osbXtqcPSr+Gfa7vDO 3v6eQI4KvHA+ro0ICz6G6+GgTbWuMJ22k3aScfGurqFD8Uo= X-Google-Smtp-Source: APXvYqxVLT0cH1OGjuCIQWQAmHzyNhlTrlnJ+MUGuEBwjEKe3MyGWhDhudf0pajjx4cZ7Up9IgGyPLR/a/hd4eYZeeo= X-Received: by 2002:ac8:470e:: with SMTP id f14mr6672736qtp.106.1571809718896; Tue, 22 Oct 2019 22:48:38 -0700 (PDT) Xref: news.gmane.org gmane.linux.lib.musl.general:14857 Archived-At: --000000000000f3221005958d775c Content-Type: text/plain; charset="UTF-8" Hi everyone, As part of my recent effort to get the D Programming Language ( https://dlang.org/) to work on Alpine Linux, I've hit what I believe is a bug in Musl. Dlang relies heavily on libc, and obviously is historically glibc-based on POSIX. When porting to Alpine/Musl, one of the unittests that failed is calling `fseek` with the value '3' for whence. The call is expected to fail, and it does on Glibc, but succeed on Musl. The reason for this difference is that Musl just forwards its whence argument to the lseek syscall, which accepts '3' (aka SEEK_DATA) as a parameter. However, glibc explicitly checks for if the value is one of SEEK_SET, SEEK_END, SEEK_CUR ( https://github.com/lattera/glibc/blob/895ef79e04a953cac1493863bcae29ad85657ee1/libio/ioseekoff.c#L32-L38), and POSIX defines the function as setting errno to EINVAL if the "whence argument is invalid" ( https://pubs.opengroup.org/onlinepubs/9699919799/functions/fseek.html). The only man page I could find that mentions 'SEEK_{DATA,HOLE}' is `lseek`'s. In light of this, it looks to me like Musl behavior is the one that should be changed. For reference, original discussions: - https://github.com/alpinelinux/aports/pull/11931#issuecomment-544831142 - https://github.com/dlang/phobos/pull/7244#issuecomment-545256706 P.S: I am not subscribed to the ML, please CC me. --000000000000f3221005958d775c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi everyone,
As part of my recent effort to get the D P= rogramming Language (https://dlang.org/)= to work on Alpine Linux, I've hit what I believe is a bug in Musl.
= Dlang relies heavily on libc, and obviously is historically glibc-based on = POSIX.

When porting to Alpine/Musl, one of the unittests=C2=A0that f= ailed is calling `fseek` with the value '3' for whence. The call is= expected to fail, and it does on Glibc, but succeed on Musl.
The reason= for this difference is that Musl just forwards its whence argument to the = lseek syscall, which accepts '3' (aka SEEK_DATA) as a parameter.
However, glibc explicitly checks for if the value is one of SEEK_SET, = SEEK_END, SEEK_CUR (https://githu= b.com/lattera/glibc/blob/895ef79e04a953cac1493863bcae29ad85657ee1/libio/ios= eekoff.c#L32-L38), and POSIX defines the function as setting errno to E= INVAL if the "whence argument is invalid" (https://pubs.op= engroup.org/onlinepubs/9699919799/functions/fseek.html). The only man p= age I could find that mentions 'SEEK_{DATA,HOLE}' is `lseek`'s.=

In light of this, it looks to me like Musl behavior is the one that= should be changed.

For reference, original discussions:
-=C2=A0<= a href=3D"https://github.com/alpinelinux/aports/pull/11931#issuecomment-544= 831142">https://github.com/alpinelinux/aports/pull/11931#issuecomment-54483= 1142
-=C2=A0https://github.com/dlang/phobos/pull/7244#issuecomment= -545256706


P.S: I am not subscribed to the ML, please CC me.=
--000000000000f3221005958d775c--