public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Lukasz Stelmach <l.stelmach@samsung.com>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: fw@deneb.enyo.de,  libc-alpha@sourceware.org,  schwab@suse.de,
	maskray@google.com,  fweimer@redhat.com,
	 adhemerval.zanella@linaro.org, joseph@codesourcery.com,
	 binutils@sourceware.org, m.pikula@partner.samsung.com,
	 m.szyprowski@samsung.com, k.lewandowsk@samsung.com
Subject: Re: global pointer gets overwritten with dlopen(3) on RISC-V
Date: Tue, 16 May 2023 08:53:03 +0200	[thread overview]
Message-ID: <oypijd5y8szs1c.fsf%l.stelmach@samsung.com> (raw)
In-Reply-To: <mhng-b599b554-275f-4115-a48a-a939ddb4a580@palmer-ri-x1c9> (Palmer Dabbelt's message of "Mon, 15 May 2023 06:47:09 -0700 (PDT)")

[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]

It was <2023-05-15 pon 06:47>, when Palmer Dabbelt wrote:
> On Fri, 12 May 2023 08:13:10 PDT (-0700), fw@deneb.enyo.de wrote:
>> * Lukasz Stelmach via Libc-alpha:
>>
>>> We've got a program (the testee) written in C that we test with another
>>> one (a testing harness, the tester) written in C++ with gtest. So far,
>>> so good. To make the testing and inspection of the internal state of the
>>> testee easier the tester does not start the testee as a separate process
>>> but loads it with dlopen(3) and calls the testee's main() function.
>>
>> We specifically disallow this in current glibc because it does not
>> work in general—unless the application is really loadable as a shared
>> object (compiled as PIC and linked with -shared).
>
> Just popping back up here, as we got lost in the ABI discussions and
> were talking about it during the glibc patchwork call: essentially it 
> boils down to us needing a more concrete reproducer for the bug.
>
> If GP is used in a shared object then we've got a bug somewhere,

No, the file we dlopen is an executable meant to work standalone. We
dlopen it for testing and this setup has worked for us on different
platforms (armv7l, aarch64, x86). We MAY have not encoutered an error
because our glibc has been patched. I have to investigate the details as
Florian brough it to our attention that an error should be reported.

> probably the linker.  There's been some debate about what things like 
> position independent mean in RISC-V land, so it's entirely possible
> there's something odd floating around here.  If you can reproduce that 
> it's probably a bug, but probably a LD/LLD bug.
>
> It sounds like there are no known bugs in glibc related to loading
> executables via dlopen(), as that doesn't work for any port due to a 
> host of reasons (GP is just one of them).  We might have some bug
> floating around, RISC-V specific or otherwise, though.  If you have a 
> reproducer for that then we can try and sort things out.

Now that I know I should get an error I will look more closely to see
what is going on.

Thank you, everyone, for your comments. They will help me a lot.
-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  parent reply	other threads:[~2023-05-16  6:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230512142114eucas1p112d969a89ad2480a0c10a532bd6d8440@eucas1p1.samsung.com>
2023-05-12 14:21 ` Lukasz Stelmach
2023-05-12 15:13   ` Florian Weimer
2023-05-15 13:47     ` Palmer Dabbelt
     [not found]       ` <CGME20230516065316eucas1p17bffcd25209bb441b9a9f4d263aa8b3c@eucas1p1.samsung.com>
2023-05-16  6:53         ` Lukasz Stelmach [this message]
2023-05-16  7:59           ` Szabolcs Nagy
2023-05-17  0:11             ` Palmer Dabbelt
2023-05-12 19:50   ` Fangrui Song
2023-05-12 20:11     ` Florian Weimer
2023-05-12 20:33       ` Palmer Dabbelt
2023-05-12 21:09         ` Fangrui Song
2023-05-12 21:57           ` Palmer Dabbelt
2023-05-12 22:34             ` Fangrui Song
2023-05-12 22:47               ` Palmer Dabbelt
2023-05-13  0:05                 ` Fangrui Song
2023-05-13  0:35                   ` Palmer Dabbelt
2023-05-16  3:56                     ` Fangrui Song
2023-05-16 22:51                       ` Palmer Dabbelt
2023-05-16 23:21                         ` Palmer Dabbelt
2023-05-12 20:35       ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=oypijd5y8szs1c.fsf%l.stelmach@samsung.com \
    --to=l.stelmach@samsung.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=binutils@sourceware.org \
    --cc=fw@deneb.enyo.de \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=k.lewandowsk@samsung.com \
    --cc=libc-alpha@sourceware.org \
    --cc=m.pikula@partner.samsung.com \
    --cc=m.szyprowski@samsung.com \
    --cc=maskray@google.com \
    --cc=palmer@dabbelt.com \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).