mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Gabriel Ravier <gabravier@gmail.com>
To: musl@lists.openwall.com, Detlef Riekenberg <wine.dev@web.de>
Subject: Re: [musl] printf does not print anything (musl 1.2.3)
Date: Thu, 13 Apr 2023 00:29:48 +0200	[thread overview]
Message-ID: <2dea9525-6a71-846b-87a6-9c743a76d3b2@gmail.com> (raw)
In-Reply-To: <trinity-539bccdc-a068-4891-8e02-d0516b5e26f0-1681335332704@3c-app-webde-bap02>

On 4/12/23 23:35, Detlef Riekenberg wrote:
> The attached test fails with musl 1.2.3 (does not print anything):
>
>
> os: xubuntu 23.04
> compiled with:  musl-gcc  -O0  -std=c99  -Wall  prog.c  -o  prog_musl-O0
> gcc: 12.2.0-17ubuntu1
>
>
> The programm is a tic-tac-toe game, but the source is stange:
> * Filesize Original: 2745 byte (includes only <stdio.h>)
> * Filesize after preprocess: with musl ~559k / with gnu libc ~571k
> * After preprocess, the format string is ~100kb
> * main() uses only one printf, and one arg has a scanf:
>
> `
> int main() {
>      while(*d) printf(fmt, arg);
> }
> `
>
> For testing, i removed the "while(*d)",
> but the binary using musl still does not print anything.
>
>
> Compiling the original source with the same gcc and using gnu libc works
> and the gnu libc version with the removed "while (*d)" produces an output of 23592 byte.
>
>
> ioccc page:  https://www.ioccc.org/2020/carlini/index.html
> Also available on github:  https://github.com/carlini/printf-tac-toe
>
>
> I tried to subscribe to the list, but i have no confirmation yet, so please cc me.
>
>
> --
> Bye bye ... Detlef

The printf call in the linked program attempts to use printf with 
numbered argument conversion specifications with a position larger than 
9 (such as 42). This is not portable to all POSIX systems, as POSIX 
specifies that the implementation need only support numbered argument 
conversion specifications with a position that is at most as large as 
the NL_ARGMAX macro (defined in limits.h), and POSIX's minimum 
requirement on the value of NL_ARGMAX is only of 9.


Thusly, musl defines NL_ARGMAX to 9 and errors on numbered argument 
conversion specifications with a position larger than it.


      reply	other threads:[~2023-04-12 22:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 21:35 Detlef Riekenberg
2023-04-12 22:29 ` Gabriel Ravier [this message]

Reply instructions:

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2dea9525-6a71-846b-87a6-9c743a76d3b2@gmail.com \
    --to=gabravier@gmail.com \
    --cc=musl@lists.openwall.com \
    --cc=wine.dev@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.vuxu.org/mirror/musl/

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).