NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/59599: libc looses environment updates made during .so initialization
The following reply was made to PR lib/59599; it has been noted by GNATS.
From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: lib/59599: libc looses environment updates made during .so
initialization
Date: Sat, 16 Aug 2025 08:10:33 +0000 (UTC)
On Fri, 15 Aug 2025, alkondratenko%gmail.com@localhost wrote:
> The fix involves updating environ variable. And things work (on GNU/Linux and FreeBSD, at least). Except on NetBSD tests failed. Debugging this I found that some dynamic linker facility is actually overwriting environ variable (presumably back to what the kernel set) after shared library initializers have run.
>
> Here is the disasm of the place that overwrites environ that I caught with some obvious gdb-ing:
>
Only tested on amd64:
```
diff -urN a/src/lib/csu/common/crt0-common.c b/src/lib/csu/common/crt0-common.c
--- a/src/lib/csu/common/crt0-common.c 2025-05-04 04:02:31.221385431 +0000
+++ b/src/lib/csu/common/crt0-common.c 2025-08-16 08:02:02.485055492 +0000
@@ -330,7 +330,8 @@
_FATAL("ps_strings missing\n");
__ps_strings = ps_strings;
- environ = ps_strings->ps_envstr;
+ if (environ == NULL)
+ environ = ps_strings->ps_envstr;
if (ps_strings->ps_argvstr[0] != NULL) {
char *c;
```
-RVP
Home |
Main Index |
Thread Index |
Old Index