From: "Buchholz, Robert" <email@example.com>
To: "firstname.lastname@example.org" <email@example.com>
Subject: [musl] Bug: ftell() after fopen(..., "ab") returns 0 unless an explicit fseek() is used first
Date: Thu, 11 Aug 2022 11:14:09 +0000 [thread overview]
Message-ID: <HE1PR04MB30817A979774EB8803BE4B0490649@HE1PR04MB3081.eurprd04.prod.outlook.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]
I'm running Alpine Linux with MUSL as its standard library within a Docker container based on the official openjdk:16-jdk-alpine3.13 Alpine image.
I've used the following minimal test case:
FILE* f = fopen("foo", "wb");
fwrite("42", 3, 1, f);
f = fopen("foo", "ab");
printf("%d ", (int)ftell(f));
fwrite("42", 3, 1, f);
fseek(f, 0, SEEK_END);
On my Alpine/MUSL setup this prints "0 6" while on Ubuntu 22.04 with glibc it prints "3 6" - which I'm assuming is the expected output. So, with MUSL the second fwrite() correctly appends to the existing file, but ftell() nevertheless reports that the initial position within the file after opening it for appending is 0 and not 3.
My GCC version is "gcc (Alpine 10.2.1_pre1) 10.2.1 20201203", ldd confirms that the compiled output is linked only against "/lib/ld-musl-x86_64.so.1" and not against glibc.
I'm not subscribed to the MUSL mailing list, please CC me on replies.
[-- Attachment #2: Type: text/html, Size: 4090 bytes --]
next reply other threads:[~2022-08-11 11:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 11:14 Buchholz, Robert [this message]
2022-08-11 11:36 ` Florian Weimer
2022-08-18 0:31 ` Rich Felker
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).