From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23118 invoked from network); 15 Jul 2020 00:33:11 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 15 Jul 2020 00:33:11 -0000 Received: (qmail 26503 invoked by uid 550); 15 Jul 2020 00:33:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26472 invoked from network); 15 Jul 2020 00:33:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=3aAlL7/KfTqbXJLAdw1ms44PgroPOj1y8ufIjXpPrmg=; b=GFpQqZJSlfBusa85PQUZ1PTXpk3wOye49vfA0yOl6jeMcB15X5LOfPBbcgGzlF/8MA 1iwFU34sIESRY/xFM6ZH0DApORtKEtuX/2q1WfbFnv5CukPaG/lAdEQW57CewLuh9Gn+ VM4cECLMuoqShvQ7vusnR/JTezO53pj386z++eofInf28y+JUvw3CITp6IbL9cKJXIYQ zDEcKYInE4wGAa/kjVKMR7ZMsCWAPlVhdWaaLGlZRM6TyzyJoouq+7ELVFhahkvuMkZb ozKaphJCWIBiQsFFm6rJOxurWETw5QhRmUdo1izg5J1DdpSgVwsg3cn2xLxP3bB4h1xX oLdA== 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=3aAlL7/KfTqbXJLAdw1ms44PgroPOj1y8ufIjXpPrmg=; b=D+QalVS3taX7JEgrcQVjCqJ1kCZMV/gOcVYiRR8LyN5O6jUlNdmVfUHx63nGOff6V4 8Y4vbO1rRaIDF7djMuRE3vGh8jisTi8DndUzMNvvXGp46SauiylvtueEjUER292nHbQd 6e3oTeyVZ9hEOF9KkPK9twPVECXcjbqkTnUxuoepLJKqEnZWcvfC8/EUhJi27VZzCiz2 6Zf7zF3Jh3Ifp6USdNKIrTL3Ls4eYExHsfxgLr3T1Bdxj8ORddA9EOOFb2Wf+0sVzkN9 03iSRUhFrK4x3guYeAdnkokneSWwImXEnNrnnfuQZkLHIHyumT8fc0TXdfC++Z7kkILr 3Q6w== X-Gm-Message-State: AOAM533/rvsEaobGLQ4pGJt9iDiHt6zhagRvxPVQeng19YTTooKt+qbu gYPKqsfGYzybjPUBUOW5nI6gKzW2mRtFeWTH7517odkk X-Google-Smtp-Source: ABdhPJxyhlJBpLU3MH9vRNbM/3zGrX/73TcR8Cyz0FW9SeozVncq+/LRu+v/F8hT151+IR2zV8alUlahZUqdOTWnt0c= X-Received: by 2002:a17:906:5909:: with SMTP id h9mr7170983ejq.501.1594773173766; Tue, 14 Jul 2020 17:32:53 -0700 (PDT) MIME-Version: 1.0 From: Simon Date: Tue, 14 Jul 2020 17:32:42 -0700 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000850f8805aa70106b" Subject: [musl] musl attribute constructor does not pass argc and argv as expected? --000000000000850f8805aa70106b Content-Type: text/plain; charset="UTF-8" Hello! I tried compiling the test.c snippet here [1] with glibc and musl under Alpine 3.12 and get the following results: $ gcc -std=c99 -o test test.c # glibc $ ldd ./test linux-vdso.so.1 (0x00007ffd0bfc9000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd1e9363000) /lib64/ld-linux-x86-64.so.2 (0x00007fd1e9572000) $ ./test arg1 arg2 stuff: argv[0] = './test' stuff: argv[1] = 'arg1' stuff: argv[2] = 'arg2' main: argv[0] = './test' main: argv[1] = 'arg1' main: argv[2] = 'arg2' $ gcc -static -std=c99 -o test test.c # musl $ ldd ./test statically linked $ ./test arg1 arg2 Segmentation fault (core dumped) $ ./test arg1 arg2 main: argv[0] = './test' main: argv[1] = 'arg1' main: argv[2] = 'arg2' Very infrequently when I run the musl compiled code then I get the seg fault. And the rest of the time only main() is run. If I compile without static then same thing: $ gcc -std=c99 -o test test.c # musl $ ldd ./test linux-vdso.so.1 (0x00007ffed4193000) libc.musl-x86_64.so.1 => not found $ ./test arg1 arg2 main: argv[0] = './test' main: argv[1] = 'arg1' main: argv[2] = 'arg2' $ ./test arg1 arg2 Segmentation fault (core dumped) If I add the following line of code both functions and recompile with musl under Alpine: printf("- argc=%d\n", argc); Then the it seems that argc is being passed but the wrong value: $ ./test arg1 arg2 - argc=-1988853488 - argc=3 main: argv[0] = './test' main: argv[1] = 'arg1' main: argv[2] = 'arg2' $ ./test arg1 arg2 - argc=1409286416 Segmentation fault (core dumped) Seems like a bug in musl, or what am I doing wrong? Thanks in advance! [1] https://stackoverflow.com/a/37012337/1547069 --000000000000850f8805aa70106b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello!

I tried compiling the= test.c snippet here [1] with glibc and musl under Alpine 3.12 and get the = following results:

$ gcc -std=3Dc99 -o test test.c= # glibc
$ ldd ./test
=C2=A0 =C2=A0 =C2=A0 =C2=A0 linux-vdso.s= o.1 (0x00007ffd0bfc9000)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 libc.so.6 =3D> /= lib/x86_64-linux-gnu/libc.so.6 (0x00007fd1e9363000)
=C2=A0 =C2=A0 =C2=A0= =C2=A0 /lib64/ld-linux-x86-64.so.2 (0x00007fd1e9572000)
$ ./test= arg1 arg2
stuff: argv[0] =3D './test'
stuff: argv[1] =3D = 9;arg1'
stuff: argv[2] =3D 'arg2'
main: argv[0] =3D '= ./test'
main: argv[1] =3D 'arg1'
main: argv[2] =3D 'a= rg2'

$ gcc -static -std=3Dc99 -o test test.c #= musl
$ ldd ./test =C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 statically linked
$ ./test arg1 arg2
Segmentation fault= (core dumped)
$ ./test arg1 arg2
main: argv[0] =3D './test'<= br>main: argv[1] =3D 'arg1'
main: argv[2] =3D 'arg2'

Very infrequently when I run the musl compiled code t= hen I get the seg fault. And the rest of the time only main() is run.
=

If I compile without static then same thing:
=
$ gcc -std=3Dc99 -o test test.c # musl
$ ldd ./tes= t
=C2=A0 =C2=A0 =C2=A0 =C2=A0 linux-vdso.so.1 (0x00007ffed4193000)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 libc.musl-x86_64.so.1 =3D> not found
$ ./test arg1 arg2
main: argv[0] =3D './test'
main: argv[1= ] =3D 'arg1'
main: argv[2] =3D 'arg2'
$ ./test arg1 arg2
Segmentation fault (core dumped)

If I add the following line of code both functions and recompile wi= th musl under Alpine:

=C2=A0 =C2=A0 printf("-= argc=3D%d\n", argc);

Then the it seems that = argc is being passed but the wrong value:

$ ./test= arg1 arg2
- argc=3D-1988853488
- argc=3D3
main: argv[0] =3D '= ./test'
main: argv[1] =3D 'arg1'
main: argv[2] =3D 'a= rg2'
$ ./test arg1 arg2
- argc=3D1409286416
Segmentation fault= (core dumped)

Seems like a bug in musl, or what a= m I doing wrong?

Thanks in advance!
=
--000000000000850f8805aa70106b--