Skip to content

dlopen: report the dlerror from GetHandle - #527

Open
vtushar06 wants to merge 1 commit into
coreos:mainfrom
vtushar06:dlopen-report-dlerror
Open

dlopen: report the dlerror from GetHandle#527
vtushar06 wants to merge 1 commit into
coreos:mainfrom
vtushar06:dlopen-report-dlerror

Conversation

@vtushar06

Copy link
Copy Markdown

I ran into this from the podman side - the API returns unable to open a handle to the library and there is no way to tell why libsystemd did not load. GetSymbolPointer and Close have reported dlerror() since #431, GetHandle is the one that never calls it.

The case I care about is when the file is present and dlopen still refuses, so "not found" is misleading:

old:  unable to open a handle to the library
new:  unable to open a handle to the library: /tmp/libbroken.so.0: invalid ELF header; libstrange.so: cannot open shared object file: No such file or directory

ErrSoNotFound is still wrapped so errors.Is keeps working, and the bare error is kept when dlopen gives no reason. runtime.LockOSThread for the same reason as #431.

The test fails on current main:

--- FAIL: TestGetHandleError (0.00s)
    dlopen_test.go:82: error does not mention "libstrange1.so": unable to open a handle to the library
    dlopen_test.go:82: error does not mention "libstrange2.so": unable to open a handle to the library

Context, if useful: podman-container-tools/podman#29528

GetHandle() never called dlerror() so a failed dlopen() only ever produced the
static ErrSoNotFound, with no way to tell why the library did not load.

Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant