NetBSD Problem Report #59267
From www@netbsd.org Mon Apr 7 02:53:53 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id E7A941A9239
for <gnats-bugs@gnats.NetBSD.org>; Mon, 7 Apr 2025 02:53:52 +0000 (UTC)
Message-Id: <20250407025351.8F1091A923C@mollari.NetBSD.org>
Date: Mon, 7 Apr 2025 02:53:51 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: libm: alias audit
X-Send-Pr-Version: www-1.0
>Number: 59267
>Category: lib
>Synopsis: libm: alias audit
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Apr 07 02:55:00 +0000 2025
>Originator: Taylor R Campbell
>Release: current
>Organization:
The AliasBSD Libmathemoundation
>Environment:
>Description:
I noticed VAX has some really weird libm failures, like this one:
*** Check failed: subtest 0: acosf(-1) is -1.5708 (-0xc.90fdb000000000p-3) not 3.14159 (0xc.90fdaa22168c2p-2), error 1.5 (0xc.000002p-3) > 1e-05
https://releng.netbsd.org/b5reports/vax/2025/2025.04.04.21.52.19/test.html#lib_libm_t_acos_acos_inrange
That's not acos(-1); that's asin(-1). What the heck?
Went digging and found this weak alias that some clever developer named `riastradh' put in:
96 __weak_alias(acosf, _asinf)
https://nxr.netbsd.org/xref/src/lib/libm/noieee_src/n_asincos.c?r=1.11#96
Oops. Good thing we had tests to catch this!
I grepped (really, grepped, sedded, and awked) through to find weak aliases that are not of the form __weak_alias(foo,_foo), and these are the candidate suspicious aliases I came up with:
noieee_src/n_asincos.c,__weak_alias,acosf,_asinf
noieee_src/n_atan2.c,__weak_alias,_atan2l,atan2
noieee_src/n_cosh.c,__weak_alias,_coshl,_cosh
noieee_src/n_exp.c,__weak_alias,_expl,_exp
noieee_src/n_floor.c,__weak_alias,ceill,ceil
noieee_src/n_floor.c,__weak_alias,floorl,floor
noieee_src/n_floor.c,__weak_alias,truncl,trunc
noieee_src/n_floor.c,__weak_alias,rintl,rint
noieee_src/n_fmax.c,__weak_alias,fmaxl,fmax
noieee_src/n_fmod.c,__weak_alias,fmodl,fmod
noieee_src/n_fmod.c,__weak_alias,modfl,fmod
noieee_src/n_lgamma.c,__weak_alias,lgammal,lgamma
noieee_src/n_lgamma.c,__weak_alias,lgammal_r,lgamma_r
noieee_src/n_pow.c,__weak_alias,_powf,powf
noieee_src/n_pow.c,__weak_alias,_pow,pow
noieee_src/n_pow.c,__weak_alias,_powl,pow
noieee_src/n_pow.c,__weak_alias,powl,pow
noieee_src/n_round.c,__weak_alias,roundl,round
noieee_src/n_sinh.c,__weak_alias,_sinhl,_sinh
src/s_ceil.c,__weak_alias,ceill,ceil
src/s_copysign.c,__weak_alias,copysignl,copysign
src/s_floor.c,__weak_alias,floorl,floor
src/s_modf.c,__weak_alias,modfl,modf
src/s_rint.c,__weak_alias,rintl,rint
src/s_round.c,__weak_alias,roundl,round
src/s_scalbn.c,__weak_alias,ldexpl,_scalblnl
src/s_scalbn.c,__weak_alias,ldexp,_scalbn
src/s_scalbnf.c,__weak_alias,ldexpf,_scalbnf
src/s_scalbnl.c,__weak_alias,ldexpl,_scalbnl
src/s_sincos.c,__weak_alias,sincosl,sincos
src/s_trunc.c,__weak_alias,truncl,trunc
src/w_fmod.c,__weak_alias,fmodl,fmod
The ones that are of the form __weak_alias(fool,foo) are probably fine although it'd be better to have
__strong_alias(_fool,_foo)
__weak_alias(fool,_fool)
just in case anything in libm itself tries to call fool(...), so by the #include "namespace.h" hack it will actually call _fool(...) and if applications linked against libm define their own `fool' function, libm won't inadvertently call that internally.
>How-To-Repeat:
1. start up a vax
2. while you wait for it to boot, make a peanut butter and jelly sandwich, because it takes a while for elderly hardware like this to get going, and you'll need the fortitude of a nutritious snack to keep focused as you wait
3. cd /usr/tests/lib/libm && atf-run t_acos | atf-report
4. code inspection
>Fix:
Yes, please! But let's do it systematically, not just the one acosf := _asinf mistake.
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.