Discussion:
rpctrace on a statically linked executable
Brent W. Baccala
2018-03-06 03:03:35 UTC
Permalink
Hi -

I'm confused by rpctrace's behavior on a statically linked test program.
Here's the program:

#include <stdio.h>

int main(int argc, char *argv[])
{
printf("Hello world!\n");
}

Perhaps you've seen it before :-)

When I compile the program with -static, I get an executable that works
fine, but can't be traced:

***@qemu-hurd:~# rpctrace ./hello-world
task134(pid8538)->vm_statistics () = 0 {4096 462739 56607 206740 23868
12642497 0 424184 481063 142824515 37245163 15804468 15747574}
Child 8538 Killed

A little more digging shows that the program is receiving an exception
after the vm_statistics call. It happens very early, before the C library
has set up an exception handler, so the exception goes to rpctrace itself,
but some code fiddling inside rpctrace shows it:

***@qemu-hurd:~# ./rpctrace ./hello-world
135(task134)-->134(task-1)->vm_statistics () = 0 {4096 462739 56536 206804
23868 12643374 0 424194 481436 142836984 37247781 15804960 15748056}
136(task-1)-->121(task1)->exception_raise ( 142<--144(pid8561)
134<--145(pid8561) 1 2 20) = 0x40000001 (Operation not permitted)
Child 8562 Killed

I'm stumped. Any idea why tracing a statically linked program will throw
an exception so early, and only when being traced?

agape
brent

Loading...