[39553] in Kerberos
Re: Threading support (on HP-UX)
daemon@ATHENA.MIT.EDU (Osipov, Michael \(IN IT IN\) via K)
Wed Sep 17 06:32:35 2025
Message-ID: <106a85ba-19fc-4a66-9809-8550293dc9bb@innomotics.com>
Date: Wed, 17 Sep 2025 12:31:57 +0200
Content-Language: en-US
To: Greg Hudson <ghudson@mit.edu>, kerberos@mit.edu
In-Reply-To: <d84f1782-49dd-4cde-967e-2e2c7f487b5a@mit.edu>
MIME-Version: 1.0
From: "Osipov, Michael \(IN IT IN\) via Kerberos" <kerberos@mit.edu>
Reply-To: "Osipov, Michael \(IN IT IN\)" <michael.osipov@innomotics.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: kerberos-bounces@mit.edu
Content-Transfer-Encoding: 8bit
On 2025-09-17 07:54, Greg Hudson wrote:
> On 9/16/25 14:09, Osipov, Michael (IN IT IN) via Kerberos wrote:
> > Using HP-UX 11.31 and MIT Kerberos 1.22.1.
>
> We will take pull requests to fix HP-UX support (provided that they are
> tested and complete for what they set out to do), but can't proactively
> fix things or speak authoritatively to how the code behaves on that
> platform.
I'd be happy to provide any as long as I know what constitutes a
reasonable test beyond "make check".
>>> configure: WARNING: missing thread-safe function: gethostbyname_r
>>> configure: WARNING: missing thread-safe function: getservbyname_r
>
> These functions are only used in fake-addrinfo.c. If the library winds
> up using getaddrinfo()/getnameinfo() directly (as I think it should),
> then configure.ac not finding these functions shouldn't be a concern
> aside from the spurious warnings.
Great, then let's ignore them.
>> While I was able to find the define in the generated Makefiles,
>> neither -lpthread or -mt with "grep -r ^PTHREAD_LIBS --
>> include=Makefile ."
>
> The design intent in 2005 was to avoid linking against libpthread,
> because it degraded performance in single-threaded programs. Instead,
> we use weak references (where we can) to invoke pthreads functions when
> libpthreads is loaded in the process, or do nothing when it is not.
>
> To that end, aclocal.m4 has:
>
> hpux*)
> # These are the flags that "gcc -pthread" adds. But we don't
> # want "-pthread" because that has link-time effects, and we
> # don't exclude CFLAGS when linking. *sigh*
> PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -
> D_POSIX_C_SOURCE=199506L"
>
> but I don't know if weak reference support was tested on HP-UX at the time.
Let me clarify here to the extent I can.
GCC is dead on HP-UX for a very long time, the only viable compiler is
aCC. So any change I'd target this one only.
Weak reference seems to be supported:
> root@deblndw001x:/var/tmp/ports/work/krb5-1.22.1/src
> # grep -r HAVE_PRAGMA_WEAK_REF ./include/autoconf.h
> #define HAVE_PRAGMA_WEAK_REF 1
HP aCC Programmer's Guide says about "-mt" in C mode:
> -D_REENTRANT
> -D_POSIX_C_SOURCE=199506L
> -lpthread
But important:
> NOTE: Make sure that -mt is used consistently at compile and link times. When you
> link with -mt, everything must be compiled with -mt, even if you do not think your file
> will be used in a threaded application. When you incorrectly mix and match with -mt
> you get a runtime abort with the following message:
> aCC runtime: Use of "-mt" must be consistent during both compilation and linking.
If I understand correctly we need to do:
PTHREAD_CFLAGS="-mt" IF this variable is passed to the linker as well,
not just to the compiler.
Edit, it does:
> /opt/aCC/bin/aCC -AC99 -L../../lib -Wl,+b,/opt/ports/lib/hpux32 +We901 -L/opt/ports/lib/hpux32 -o kadmind auth.o auth_acl.o auth_self.o kadm_rpc_svc.o server_stubs.o ovsec_kadmd.o schpw.o misc.o ipropd_svc.o -l
> apputils -lkadm5srv_mit -lkdb5 -lgssrpc -lgssapi_krb5 -lgssrpc -lgssapi_krb5 -mt -lkrb5 -lk5crypto -lcom_err -lkrb5support -lintl -lverto
> It's probable that this 2005 design qualifies as too clever in 2025.
> OpenSSL's libcrypto appears to link directly against libpthread, and it
> is a much more widely-used library than libkrb5 or libgssapi_krb5.
Yes, that is the case here as well:
> # ldd $(which openssl)
>
> /opt/ports/bin/openssl:
> libssl.so.3 => /opt/ports/lib/hpux32/libssl.so.3
> libcrypto.so.3 => /opt/ports/lib/hpux32/libcrypto.so.3
> libdl.so.1 => /usr/lib/hpux32/libdl.so.1
> libpthread.so.1 => /usr/lib/hpux32/libpthread.so.1
> libc.so.1 => /usr/lib/hpux32/libc.so.1
Let me know what you think and whether I can provide you any guide
off-list to confirm my understanding.
Ran now "make check", found a bug (several scripts/Makefile.in hardcode
awk and HP awk is broken, gawk works. Fixed inline). It runs, but fails
here:
> SHLIB_PATH=`echo -L../../lib | sed -e "s/-L//g" -e "s/ /:/g"` KRB5_CONFIG=../../config-files/krb5.conf LC_ALL=C ./t_imp_name
> if [ -r ../../lib/libgssapi_krb5.so ]; then SHLIB_PATH=`echo -L../../lib | sed -e "s/-L//g" -e "s/ /:/g"` KRB5_CONFIG=../../config-files/krb5.conf LC_ALL=C ./reload; fi
> Assertion failed: destructors_set[keynum] == 0, file threads.c, line 351
> /bin/sh: 11962 Abort(coredump)
> gmake[2]: *** [Makefile:655: check-unix] Error 134
> gmake[2]: Leaving directory '/var/tmp/ports/work/krb5-1.22.1/src/tests/gssapi'
> gmake[1]: *** [Makefile:1209: check-recurse] Error 1
> gmake[1]: Leaving directory '/var/tmp/ports/work/krb5-1.22.1/src/tests'
> gmake: *** [Makefile:1537: check-recurse] Error 1
But fails without -mt as well.
Shall I raise a PR for -mt?
Michael
________________________________________________
Kerberos mailing list Kerberos@mit.edu
https://mailman.mit.edu/mailman/listinfo/kerberos