From nobody Mon Jan 27 04:54:19 2025 X-Original-To: freebsd-hackers@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 4YhGKx25XGz5mCg4 for ; Mon, 27 Jan 2025 04:54:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4YhGKw70Cbz4PbD for ; Mon, 27 Jan 2025 04:54:28 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 50R4sK8j029809; Mon, 27 Jan 2025 06:54:23 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 50R4sK8j029809 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 50R4sJqN029808; Mon, 27 Jan 2025 06:54:19 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 27 Jan 2025 06:54:19 +0200 From: Konstantin Belousov To: Steve Kargl Cc: freebsd-hackers@freebsd.org Subject: Re: gcc14 static linking ends with segfault Message-ID: References: List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Rspamd-Queue-Id: 4YhGKw70Cbz4PbD X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] On Sun, Jan 26, 2025 at 12:16:53PM -0800, Steve Kargl wrote: > In replacing an ancient system with new I re-installed all ports > including lang/gcc14 of FreeBSD-current. -current is 2 day old > sources. > > Consider, > > #include > #include > #include "mpfr.h" > > int > main(void) > { > mpfr_t pi; > mpfr_inits2(512, pi, NULL); > mpfr_const_pi(pi, MPFR_RNDN); > mpfr_printf("pi = %25.20Rf\n", pi); > // A conscientious programmer cleans up after themself, > // but on exit the system should take care of memory. > // mpfr_clears(pi, NULL); > return (0); > } > > % gcc14 -o z -O2 -I/usr/local/include a.c -L/usr/local/lib -lmpfr -lgmp > % ./z > pi = 3.14159265358979323846 > > All seems to work with shared linking. > > The following used to work. > > % gcc14 -o z -O2 -I/usr/local/include a.c -L/usr/local/lib -lmpfr -lgmp \ > -static > % ./z > pi = 3.14159265358979323846 > Segmentation fault (core dumped) > > % gdb151 ./z z.core > ... > #0 0x0000000000427ba5 in __gmpn_mul_1 () > (gdb) bt > #0 0x0000000000427ba5 in __gmpn_mul_1 () > #1 0x000000000040051f in __do_global_dtors_aux () > at /usr/src/lib/csu/common/crtbegin.c:83 > #2 0x00000000004bc165 in _fini () > #3 0x0000000000458a7f in __cxa_finalize (dso=dso@entry=0x0) > at /usr/src/lib/libc/stdlib/atexit.c:234 > #4 0x0000000000458b70 in exit (status=0) at /usr/src/lib/libc/stdlib/exit.c:89 > #5 0x00000000004483d9 in __libc_start1 (argc=1, argv=0x820a52900, > env=0x820a52910, cleanup=, mainX=0x400480
) > at /usr/src/lib/libc/csu/libc_start1.c:172 > #6 0x00000000004004f0 in _start () at /usr/src/lib/csu/amd64/crt1_s.S:83 > > So, did someone break the startup files? Why do you think that startup (crt) files are broken? Note that they are involved in the trace above, but the lowest frame is from gmp destructor, i.e. the problem formally happens in the gmp code. Perhaps try to rebuild gmp with debug info to get more information.