Index | Thread | Search

From:
Philip Guenther <guenther@gmail.com>
Subject:
Fwd: [PATCH]: Add missing POSIX psiginfo(3) call
To:
tech-openbsd <tech@openbsd.org>
Date:
Mon, 4 Aug 2025 18:56:55 -0700

Download raw body.

Thread
fucking gmail UX

---------- Forwarded message ---------
From: Philip Guenther <guenther@gmail.com>
Date: Mon, Aug 4, 2025 at 6:56 PM
Subject: Re: [PATCH]: Add missing POSIX psiginfo(3) call
To: Ricardo Branco <rbranco@suse.de>


Anyone making non-cosmetic changes to system libs should be using
/usr/src/lib/check_syms to review the effect of their change.  If
they're not adding and deleting interfaces, it should report no
changes.  If they are, it should report just the changes they expect.

Running that with this diff reports this:

$ ../check_sym
/usr/lib/libc.so.101.0 --> obj/libc.so.101.0
Dynamic export changes:
added:
        psiginfo

PLT added:
        psignal

$

Wait, what?  Why is it reporting that there's a psignal "PLT" added?

PLT stands for Procedure Lookup Table and is how ELF implemented
indirection in function-call lookups that may go cross-DSO.

When writing the diff you certainly noticed this line right next to
the one you added:
  PROTO_DEPRECATED(psignal);

If you go looking for what that means, you would find
lib/libc/include/README which explains that that macro,
PROTO_DEPRECATED, is used for functions which are *not called from
inside libc*.  Indeed, it marks the function with the 'deprecated'
attribute so that uses of it will generate warnings.

...but this diff adds such a call!

(I'm not sure why it doesn't generate a deprecation warning, at least
not with clang on amd64.  I suspect the warning doesn't fire in the
same translation unit where the target is defined, perhaps because it
was completely inlined.  <sigh>)

The result is that this diff creates an unnecessary PLT entry:
psiginfo() should always use the psignal implementation that's right
next to it in libc, but without jockeying the standard behavior
doesn't get you that.  The solution in this case is to review
lib/libc/include/README for what to do with functions that _are_
called internally and adjust psignal to match.  In particular, the
PROTO_DEPRECATED(psignal) should change to PROTO_NORMAL(psignal) and a
    DEF_WEAK(psignal);

line should be added after the declaration of psignal() itself in gen/psignal.c

Since psiginfo() is such a dumb function (it's a fucking struct
pointer deref different from psignal()!) it should perhaps:
 * be put into its own .c file, thus avoiding the duplication of object code
    - this would also have triggered the deprecation warning.  Bonus!
 * have a static inline provided in <signal.h> to put that oh so hard
lookup in the caller when possible


Philip Guenther