Igalia / webkit-container-sdk

The all-in-one SDK for WebKit GTK/WPE port development.
MIT License
12 stars 7 forks source link

gdb failing to obtain symbols when attaching #61

Open ntrrgc opened 1 month ago

ntrrgc commented 1 month ago

In the past this has worked for me, but today I found this in my laptop while trying to attach gdb. Both gdb and WebKitWebProcess are running in the same container:

$ gdb
(gdb) attach 361837
Attaching to program: /host/home/ntrrgc/Apps/webkit/WebKitBuild/GTK/Debug/bin/WebKitWebProcess, process 361837
[New LWP 423389]
[New LWP 423367]
...
Error while mapping shared library sections:
Could not open `target:/host/home/ntrrgc/Apps/webkit/WebKitBuild/GTK/Debug/lib/libwebkitgtk-6.0.so.4' as an executable file: Operation not permitted
Error while mapping shared library sections:
Could not open `target:/lib/x86_64-linux-gnu/libepoxy.so.0' as an executable file: Operation not permitted
Error while mapping shared library sections:
Could not open `target:/lib/x86_64-linux-gnu/libfontconfig.so.1' as an executable file: Operation not permitted
(... tons of similar errors ...)
(gdb) bt
#0  0x00007fbc3652725d in ?? ()
#1  0x00007fbc36b6d40d in ?? ()
#2  0x0000000000020000 in ?? ()
#3  0x0000000000000001 in ?? ()
#4  0x00007fbc35f2d3e0 in ?? ()
#5  0x0000000000000001 in ?? ()
#6  0x00007fbc35f6cc70 in ?? ()
#7  0x000055f323a1bba0 in ?? ()
#8  0x00007fbc35f19768 in ?? ()
#9  0x00007fbc35e9c7da in ?? ()
#10 0x00007fbc3d6c1390 in ?? ()
#11 0x000055f323a1bc38 in ?? ()
#12 0x0000000000000002 in ?? ()
#13 0x00007ffe80525c60 in ?? ()
#14 0x000055f323a1bba0 in ?? ()
#15 0x00007ffe80525d90 in ?? ()
#16 0x0000000000000000 in ?? ()
q66 commented 1 month ago

this should only really happen when the process and the debugger run in different namespaces, so likely interference from the bwrap sandbox? (try forcing it off, there is an env var for it)

ntrrgc commented 1 month ago

@q66 shouldn't it work regardless? I would expect attaching a debugger to be something that works by default.

TingPing commented 1 month ago

Inside the SDK the sandbox disables the pid namespacing.

FWIW it works fine here.

q66 commented 1 month ago

@ntrrgc it probably should, but that's separate from what i said :) i'm just trying to find the cause of the error here

ntrrgc commented 1 month ago

@q66 I just tried with WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS=1 and it found the symbols. So that's confirmed at least.

q66 commented 1 month ago

@ntrrgc the pid namespace is unshared when enableDebugPermissions() returns false https://github.com/WebKit/WebKit/blob/b1ed27f4948073a31795dc90b845554fda214420/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp#L784

looking at that, it checks an env var: https://github.com/WebKit/WebKit/blob/b1ed27f4948073a31795dc90b845554fda214420/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp#L465

so next thing you can try is setting WEBKIT_ENABLE_DEBUG_PERMISSIONS_IN_SANDBOX=1 in the environment instead of a full disable

if that works, and if what Patrick says is correct, it would mean your configuration having that messed up for some reason (but i dunno enough about how the container sdk works to tell by myself)

ntrrgc commented 1 month ago

The issue still happens with WEBKIT_ENABLE_DEBUG_PERMISSIONS_IN_SANDBOX=1.

q66 commented 1 month ago

hm, maybe it's one of the other namespaces then? or some change in bwrap behavior? the only ones the launcher seems to use are user, pid, ipc, uts, and network... doesn't sound like any of the others should be relevant

would need somebody to collect a bunch more information i guess...