From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id CEFD7213D9 for ; Thu, 4 Apr 2024 23:19:32 +0200 (CEST) Received: (qmail 27922 invoked by uid 550); 4 Apr 2024 21:19:25 -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 27884 invoked from network); 4 Apr 2024 21:19:25 -0000 Date: Thu, 4 Apr 2024 21:18:26 +0000 (UTC) From: Thorsten Glaser X-X-Sender: tg@herc.mirbsd.org To: musl@lists.openwall.com cc: 1068350@bugs.debian.org, debian-glibc@lists.debian.org, doko@debian.org In-Reply-To: Message-ID: References: <171218457890.157989.17235252523998125898.reportbug@zelenka.debian.org> <20240404104428.GA3766212@port70.net> <20240404105408.GB3766212@port70.net> <20240404202641.GS4163@brightrain.aerifal.cx> Content-Language: de-Zsym-DE-1901-u-em-text-rg-denw-tz-utc, en-Zsym-GB-u-cu-eur-em-text-fw-mon-hc-h23-ms-metric-mu-celsius-rg-denw-tz-utc-va-posix MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Subject: [musl] =?utf-8?Q?Re=3A_Bug#1068350=3A_musl=3A_miscompiles_=28runtime_p?= =?utf-8?Q?roblems=29_on_riscv64_and_s390x_with_static-pie_?= =?utf-8?Q?=E2=86=92_seems_to_be_a_toolchain_bug_after_all?= =?utf-8?Q?=2C_it_does_too_hit_glibc?= Dixi quod=E2=80=A6 >Hmm, actually=E2=80=A6 I could=E2=80=A6 test whether that one fixes static= -pie >on zelenka. Or at least the same approach. I=E2=80=99ll get back with >report from that. Having looked at the spec file, the only extra things the stock specs do that the overriding specs don=E2=80=99t is: *link: [=E2=80=A6] %{!static|static-pie:--eh-frame-hdr} [=E2=80=A6] %{static-pie:-= static -pie --no-dynamic-linker -z text} [=E2=80=A6] instead of: [=E2=80=A6] %{static-pie:-static -pie --no-dynamic-linker} [=E2=80=A6] The -Wl,-z,text makes TEXTRELs an error. Granted. The -Wl,--eh-frame-hdr is added for anything that=E2=80=99s not a normal static executable, however adding that to a musl build doesn=E2=80=99t fix the problem either. A bit of gdb-ing shows the problem, though: the source code has=E2=80=A6 #define Ttypeset "typeset" #define Tdr "-r" //=E2=80=A6 (a variant of this is used for string sharing on ancient Unix) static const char *initcoms[] =3D { =09Ttypeset, Tdr, initvsn, NULL, =09Ttypeset, Tdx, "HOME", TPATH, TSHELL, NULL, [=E2=80=A6] }; It then iterates over these commands with: for (wp =3D initcoms; *wp !=3D NULL; wp++) { =09c_builtin(wp); =09while (*wp !=3D NULL) =09=09wp++; } This is where the extra output happens: (gdb) print initcoms $3 =3D {0x3fff7fc14a4 "typeset", 0x0, 0x0, 0x0, 0x3fff7fc14a4 "typeset", 0x= 0, 0x3fff7fc0478 "HOME",=20 [=E2=80=A6] Notice the nullptrs there where string pointers are expected. It shows the same output when just loading the executable, i.e. this isn=E2=80=99t a runtime issue. Linking the exact same .o files with the exact same command minus -static-pie gives: (gdb) print initcoms $1 =3D {0x103cb34 "typeset", 0x103e368 "-r",=20 0x103e73c "KSH_VERSION=3D@(#)MIRBSD KSH R59 2024/02/01 +Debian"= , 0x0, 0x103cb34 "typeset",=20 But this does seem to be a toolchain bug: adding -static-pie to the glibc dynamic-pie link command and=E2=80=A6 (gdb) print initcoms $1 =3D {0xda494 "typeset", 0x0, 0x0, 0x0, 0xda494 "typeset", 0x0, 0xd942c "= HOME", 0xda7d8 "PATH", Now I (or someone) is going to have to reduce that to a testcase, so we can detect static-pie viability before it=E2=80=99s committed to being u= sed=E2=80=A6 bye, //mirabilos --=20 Solange man keine schmutzigen Tricks macht, und ich meine *wirklich* schmutzige Tricks, wie bei einer doppelt verketteten Liste beide Pointer XORen und in nur einem Word speichern, funktioniert Boehm ganz hervorragend.=09=09-- Andreas Bogk =C3=BCber boehm-gc in d.a.s.r