Re: Regression tests fail with musl libc because libpq.so can't be loaded

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Wolfgang Walther <walther(at)technowledgy(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Regression tests fail with musl libc because libpq.so can't be loaded
Date: 2024-03-18 13:25:33
Message-ID: CA+hUKGJW_ht0VYsr7bzF8-FLZW_o3Ys6Xm5w10GU5WBHtfv+zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, Mar 18, 2024 at 10:34 PM Christophe Pettus <xof(at)thebuild(dot)com> wrote:
> > On Mar 17, 2024, at 16:20, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> > We'd
> > still feel free to clobber the memory up to that point (rather than
> > limiting ourselves to the argv space, another more conservative choice
> > that might truncate a few PS display messages, or maybe not given the
> > typical postmaster arguments, maye that'd work out OK), and we'd still
> > copy the environment to somewhere new, but anything like "LD_XXX" that
> > the runtime linker might have stashed a pointer to would remain valid.
> > /me runs away and hides
>
> It doesn't lack for bravery! (And I have to just comment that the linker storing pointers into that space as a way of finding libraries... well, that doesn't get them the moral high ground for nasty hacks.)

FWIW here is a blind patch if someone wants to try it out... no musl here.

(Hmm, I think it's not that unreasonable on their part to assume the
initial environment is immutable if their implementation doesn't
mutate it, and our doing so is undeniably UB; surprising, maybe, given
that the technique works on that other popular brand of C library on
that kind of kernel, not to mention dozens of old Unixen of yore...
The real solution may turn out to be the prctl() described in that
thread, where you can tell the kernel where you're planning to move
your argv and it can find it to show ps/top, but I checked and you
still can't call that without special privileges, so maybe someone
should get onto complaining to kernel hackers about that? That thread
is wrong about us clobbering auxv BTW, we're not animals!)

Attachment Content-Type Size
0001-Don-t-clobber-LD_-environment-variables.patch application/octet-stream 2.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-03-18 14:05:58 BUG #18398: Simplified SQL Query for Problem Diagnosis
Previous Message Christophe Pettus 2024-03-18 09:33:45 Re: Regression tests fail with musl libc because libpq.so can't be loaded

Browse pgsql-hackers by date

  From Date Subject
Next Message Sean 2024-03-18 13:29:11 Is there still password max length restrictions in PG?
Previous Message Matthias van de Meent 2024-03-18 13:24:46 Re: Optimizing nbtree ScalarArrayOp execution, allowing multi-column ordered scans, skip scan