From nobody Sat Jan 18 18:35:52 2025 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Yb4zw5V2Xz5kjN9 for ; Sat, 18 Jan 2025 18:35:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yb4zv6N0Tz434X for ; Sat, 18 Jan 2025 18:35:55 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737225355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KHQIbXDg0T4whsQnVCyrBr/4+eVXrABnvDS9TW8ks90=; b=u+ZLk/hfObz8sAjUfpSRHaTYRSn1bwDm0zwhChdbimIybHc1T9ucCdtOpuoTcvsBvksAO0 t+LPvdbJAW1H/+hQYWE8Ze3PjTodzxXeURelYBHVOOTTvEEjcD6yH9MBBPsxSzaCVNwriV UUYqf1t66SngaJb8CueKlq6LchdobUy7+gdNPPffwZ6Js77UjiQQtKwm+bhTvuq+A734xK ralnnlloVxtdQEuOYj7gt7i1Bm93XnMJvHKZ2kAM6vs77rAlJKADx/HCuIX5LrJu6eRhqb bM5TwfvrhsacfDybN6VylhB4F6xG8I7nwCdNBQq9IqS4Qsi0wYucRld8mEZ7QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737225355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KHQIbXDg0T4whsQnVCyrBr/4+eVXrABnvDS9TW8ks90=; b=jN+TKWUMqemQ+2b31yIOPxVQ4Rilnw0s6gqMruVS0901FnvVii/0fTYd16z4/joKp+ZsK0 6Jm0L8u97B/7AniPqBhEoUj/i2fP0W7CSp+0wl7LdnxW81YCNVXG1QBwoGRVXX7Q7ou5O+ 2oGK+NHKeQ6o9CqfcbXJAbtlRSswAV3qgIIS197AHoJtXranKDeO/qbuZ/H8kpoFZtquAH jHZPscr5lFZDaVHAv2dNE0SRSckKFHg3GxLk4Wl0g/WuQRidyHpCz6KfTyVMUoHcBIxegQ BuY22rAOZ2wC6nirumElMJaJAIoxCj89guSSduJ62+0mDwJXb1t4u8ABhJJZcg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737225355; a=rsa-sha256; cv=none; b=Dkl28HmW28RXBxYrvRgR/Fj875PrFzDmLlBVpeO8j9N6QWQuQGfVrvghhFsLMJaSk34EDF 0k+dMbYTEwcL9wIgTgNStzQvf37RpJ6fiXXPVQwODmoqV08hZe6OkzXPv1+vd6U/R4pncd nxEvIxnQVGQ8CxghPVK+20S6z3hFTk/5Mrtrp2vIlgxFn6+qWWtmuMGklA4/5U8oYqh35f q7wtXvJCwbPKltAhgwKMt+skI9PGjZPDeKTCJGcrtz2KMza7wtvL6UPACmUkkCZWP24jnt CGNEcJLY2fLDs/WDJ77wFKVkZUApjg0Vo40IMRtosfcLEKWPXC+nmv6nD1Qyow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Yb4zv5gxzz1NJ for ; Sat, 18 Jan 2025 18:35:55 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 50IIZt4i055629 for ; Sat, 18 Jan 2025 18:35:55 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 50IIZtqb055628 for bugs@FreeBSD.org; Sat, 18 Jan 2025 18:35:55 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 235751] Failure to init TLS variables with func ptr inside shared lib Date: Sat, 18 Jan 2025 18:35:52 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 14.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dclarke@blastwave.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: rep_platform version Message-ID: In-Reply-To: References: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235751 Dennis Clarke changed: What |Removed |Added ---------------------------------------------------------------------------- Hardware|powerpc |amd64 Version|12.0-RELEASE |14.2-RELEASE --- Comment #6 from Dennis Clarke --- (In reply to Mark Linimon from comment #5) Seems yes on AMD64 and also on IBM POWER9 ppc64le. ******************* tests ************************** [1] test on AMD64 with FreeBSD 14.2-RELEASE hydra$ uname -apKU=20 FreeBSD hydra 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC amd64 amd64 1402000 1402000 hydra$ freebsd-version -kru=20 14.2-RELEASE 14.2-RELEASE 14.2-RELEASE hydra$ which cc /usr/bin/cc hydra$ CC=3D/usr/bin/cc hydra$ export CC hydra$ $CC --version FreeBSD clang version 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67) Target: x86_64-unknown-freebsd14.2 Thread model: posix InstalledDir: /usr/bin hydra$ $CC -std=3Diso9899:1999 -pedantic -pedantic-errors -m64 -g -O0 -fno-builtin -shared -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600 -D_REENTRANT -o t1.so -fPIC t1.c hydra$ echo $? 0 hydra$ $CC -std=3Diso9899:1999 -pedantic -pedantic-errors -m64 -g -O0 -fno-builtin -shared -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600 -D_REENTRANT -o foo t2.c t1.so hydra$ file foo foo: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, for FreeBSD 14.2, with debug_info, not stripped hydra$ readelf -delV foo | grep -E 'NEED|NAME|PATH' 0x0000000000000001 NEEDED Shared library: [t1.so] 0x0000000000000001 NEEDED Shared library: [libc.so.7] 0x000000006ffffffe VERNEED 0x340 0x000000006fffffff VERNEEDNUM 1 hydra$=20 hydra$ ./foo Segmentation fault (core dumped) hydra$=20 hydra$ LD_LIBRARY_PATH=3D`pwd` ./foo Segmentation fault (core dumped) hydra$=20 hydra$ TERM=3Ddumb LD_LIBRARY_PATH=3D`pwd` gdb ./foo GNU gdb (GDB) 15.1 [GDB v15.1 for FreeBSD] Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-portbld-freebsd14.1". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./foo... (gdb) run Starting program: /home/dclarke/tls/foo=20 Program received signal SIGSEGV, Segmentation fault. Invalid permissions for mapped object. 0x0000000001021000 in ?? () (gdb) where #0 0x0000000001021000 in ?? () #1 0x0000000000000000 in ?? () (gdb) quit A debugging session is active. Inferior 1 [process 14818] will be killed. Quit anyway? (y or n) y With or without the debugger we still get a SIGSEGV : hydra$ TERM=3Ddumb LD_LIBRARY_PATH=3D`pwd` ./foo Segmentation fault (core dumped) hydra$=20 ************************************** [2] 15.0-CURRENT on AMD64 :=20 titan$ uname -apKU FreeBSD titan 15.0-CURRENT FreeBSD 15.0-CURRENT #5 main-n274856-488660360a7= 1: Sat Jan 18 17:03:26 GMT 2025=20=20=20=20 root@titan:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 amd64 150= 0030 1500030 titan$=20 titan$ CC=3D/usr/bin/cc titan$ export CC titan$=20 titan$ $CC --version FreeBSD clang version 19.1.7 (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd708029e0b2) Target: x86_64-unknown-freebsd15.0 Thread model: posix InstalledDir: /usr/bin Build config: +assertions titan$=20 titan$ $CC -std=3Diso9899:1999 -pedantic -pedantic-errors -m64 -g -O0 -fno-builtin -shared -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600 -D_REENTRANT -o t1.so -fPIC t1.c titan$ $CC -std=3Diso9899:1999 -pedantic -pedantic-errors -m64 -g -O0 -fno-builtin -shared -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600 -D_REENTRANT -o foo t2.c t1.so titan$=20 titan$ file foo foo: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, for FreeBSD 15.0 (1500030), with debug_info, not stripped titan$=20 titan$=20 titan$ readelf -delV foo | grep -E 'NEED|NAME|PATH' 0x0000000000000001 NEEDED Shared library: [t1.so] 0x0000000000000001 NEEDED Shared library: [libc.so.7] 0x000000006ffffffe VERNEED 0x340 0x000000006fffffff VERNEEDNUM 1 titan$=20 titan$ ./foo Segmentation fault (core dumped) titan$=20 titan$ LD_LIBRARY_PATH=3D`pwd` ./foo Segmentation fault (core dumped) titan$=20 titan$ TERM=3Ddumb LD_LIBRARY_PATH=3D`pwd` gdb ./foo GNU gdb (GDB) 15.1 [GDB v15.1 for FreeBSD] Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-portbld-freebsd15.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./foo... (gdb) run Starting program: /home/dclarke/pgm/bw/in_progress/tls/foo=20 Program received signal SIGSEGV, Segmentation fault. Invalid permissions for mapped object. 0x0000000001021000 in ?? () (gdb) where #0 0x0000000001021000 in ?? () #1 0x0000000000000001 in ?? () #2 0x00007fffffffec70 in ?? () #3 0x0000000000000000 in ?? () (gdb) quit A debugging session is active. Inferior 1 [process 5060] will be killed. Quit anyway? (y or n) y titan$=20 *********************************************************** [3] 14.2-RELEASE FreeBSD on powerpc64le scotty$=20 scotty$ uname -apKU FreeBSD scotty 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC powerpc powerpc64le 1402000 1402000 scotty$=20 scotty$ sysctl hw.model hw.model: IBM POWER9 scotty$=20 scotty$ CC=3D/usr/bin/cc scotty$ export CC scotty$=20 scotty$ $CC --version FreeBSD clang version 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67) Target: powerpc64le-unknown-freebsd14.2 Thread model: posix InstalledDir: /usr/bin scotty$=20 scotty$ $CC -std=3Diso9899:1999 -pedantic -pedantic-errors -m64 -g -O0 -fno-builtin -shared -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600 -D_REENTRANT -o t1.so -fPIC t1.c scotty$ $CC -std=3Diso9899:1999 -pedantic -pedantic-errors -m64 -g -O0 -fno-builtin -shared -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600 -D_REENTRANT -o foo t2.c t1.so scotty$ file foo foo: ELF 64-bit LSB shared object, 64-bit PowerPC or cisco 7500, OpenPOWER = ELF V2 ABI, version 1 (FreeBSD), dynamically linked, for FreeBSD 14.2, with debug_info, not stripped scotty$=20 scotty$ readelf -delV foo | grep -E 'NEED|NAME|PATH' 0x0000000000000001 NEEDED Shared library: [t1.so] 0x0000000000000001 NEEDED Shared library: [libc.so.7] 0x000000006ffffffe VERNEED 0x340 0x000000006fffffff VERNEEDNUM 1 scotty$=20 scotty$ ./foo Segmentation fault (core dumped) scotty$=20 *********************************************** other systems and compiler tools *********************************************** For the sake of a comparison I will change the return value to 42 and do the same test on a Solaris 10 SPARCv9 Fujitsu server using an entirely different set of tools :=20 hubble $ uname -a=20 SunOS hubble 5.10 Generic_150400-67 sun4u sparc SUNW,SPARC-Enterprise hubble $=20 hubble $ echo $CC /opt/developerstudio12.6/bin/cc hubble $=20 hubble $ $CC -V cc: Studio 12.6 Sun C 5.15 SunOS_sparc 2017/05/30 hubble $=20 hubble $ cat t2.c /* as seen at * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235751 */ struct s_t { int (*func)(int); }; extern struct s_t __thread x; int main(int argc, const char *argv[]) { return (*x.func)(argc+41); } hubble $=20 hubble $ echo $CFLAGS -m64 -xarch=3Dsparc -g -xO0 -mc -xs -errfmt=3Derror -erroff=3D%none -errsho= rt=3Dfull -errtags=3Dyes -errwarn=3D%none -ftrap=3D%none -xbuiltin=3D%none -xildoff -= xlibmieee -xstrconst -xcode=3Dpic32 -xmemalign=3D8s -xnolibmil -xunroll=3D1 -xdepend -xregs=3Dno%appl -xdebugformat=3Ddwarf hubble $=20 hubble $ echo $CPPFLAGS -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600 -D_POSIX_PTHREAD_SEMANTICS -D_TS_ERRNO hubble $=20 hubble $ $CC $CFLAGS -G $CPPFLAGS -D_REENTRANT -o t1.so -h t1.so t1.c hubble $ file t1.so t1.so: ELF 64-bit MSB dynamic lib SPARCV9 Version 1, dynamically linked, not stripped hubble $=20 hubble $ $CC $CFLAGS $CPPFLAGS -D_REENTRANT -o foo t2.c t1.so hubble $=20 hubble $ elfdump -delv foo | grep -E 'NEED|NAME|PATH' [0] NEEDED 0xe3 t1.so [1] NEEDED 0xd0 libc.so.1 [4] RUNPATH 0xe9 /opt/bw/lib [5] RPATH 0xe9 /opt/bw/lib [12] VERNEED 0x1000007a8=20=20=20=20=20=20=20=20=20 [13] VERNEEDNUM 0x1=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 hubble $=20 hubble $ ldd foo t1.so =3D> (file not found) libc.so.1 =3D> /lib/64/libc.so.1 libm.so.2 =3D> /lib/64/libm.so.2 /lib/sparcv9/../libm/sparcv9/libm_hwcap1.so.2 /platform/SUNW,SPARC-Enterprise/lib/sparcv9/libc_psr.so.1 hubble $=20 hubble $ LD_LIBRARY_PATH=3D`pwd` ./foo hubble $ echo $? 42 hubble $=20 So that seems to work there. Here is an IBM POWER9 server with the IBM XLC compiler :=20 dax$ uname -a=20 Linux dax 6.1.118-mrw1 #1 SMP Sun Nov 17 22:40:36 PST 2024 ppc64le GNU/Linux dax$=20 dax$ CC=3D/opt/ibm/xlC/16.1.1/bin/xlc dax$ export CC dax$=20 dax$ CFLAGS=3D'-qlanglvl=3Dstdc99 -O0 -g' dax$ export CFLAGS dax$=20 dax$ CPPFLAGS=3D'-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -D_XOPEN_SOURCE=3D600' dax$ export CPPFLAGS dax$=20 dax$ $CC $CFLAGS $CPPFLAGS -D_REENTRANT -shared -fPIC -o t1.so t1.c dax$ file t1.so=20 t1.so: ELF 64-bit LSB shared object, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), dynamically linked, with debug_info, not stri= pped dax$=20 dax$ $CC $CFLAGS $CPPFLAGS -D_REENTRANT -o foo t2.c t1.so=20 dax$ ldd foo linux-vdso64.so.1 (0x00007fff83650000) t1.so =3D> not found libgcc_s.so.1 =3D> /lib/powerpc64le-linux-gnu/libgcc_s.so.1 (0x00007fff835e0000) libm.so.6 =3D> /lib/powerpc64le-linux-gnu/libm.so.6 (0x00007fff834b= 0000) libc.so.6 =3D> /lib/powerpc64le-linux-gnu/libc.so.6 (0x00007fff8320= 0000) /lib64/ld64.so.2 (0x00007fff83660000) dax$=20 dax$ LD_LIBRARY_PATH=3D`pwd` ./foo dax$ echo $? 42 dax$=20 I have not bothered to look on RISC-V yet. --=20 -- Dennis Clarke RISC-V/SPARC/PPC/ARM/CISC UNIX and Linux spoken --=20 You are receiving this mail because: You are the assignee for the bug.=