Bug 17231 - sysroot is too often prepended
Summary: sysroot is too often prepended
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Josh Stone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-05 22:06 UTC by Josh Stone
Modified: 2016-05-23 16:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Stone 2014-08-05 22:06:21 UTC
# normal:
$ stap -l 'process("/bin/ls").function("main")' 
process("/usr/bin/ls").function("main")

# symroot identity:
$ ./stap -l 'process("/bin/ls").function("main")' --sysroot / 
process("/usr/bin/ls").function("main")

# add a trivial real symroot
$ sudo mount --bind / /mnt
$ ls -l /mnt/bin/ls
-rwxr-xr-x. 1 root root 121K Mar  5 05:09 /mnt/bin/ls
$ stap -l 'process("/bin/ls").function("main")' --sysroot /mnt --vp 02
semantic error: while resolving probe point: identifier 'process' at <input>:1:7
   thrown from: ../elaborate.cxx:1061
        source: probe process("/bin/ls").function("main") {}
                      ^

semantic error: cannot find executable '/mnt//mnt//bin/ls'
   thrown from: ../tapsets.cxx:672


The sysroot is first prepended in dwarf_builder::build(), then again when base_query::base_query() calls find_executable(), and then it fails when is_fully_resolved() compares the path to yet another find_executable().  By that time we have twice-prepended compared to thrice, which of course is not equal.


It also fails when the filename has no path to start with, which ought to search $PATH in the sysroot:

$ stap -l 'process("ls").function("main")' 
process("/usr/bin/ls").function("main")

$ stap -l 'process("ls").function("main")' --sysroot /mnt --vp 02
semantic error: while resolving probe point: identifier 'process' at <input>:1:7
   thrown from: ../elaborate.cxx:1061
        source: probe process("ls").function("main") {}
                      ^

semantic error: cannot find executable '/mnt//mnt/ls'
   thrown from: ../tapsets.cxx:672

or even:
$ stap -l 'process("ls").function("main")' --sysroot / --vp 02
semantic error: while resolving probe point: identifier 'process' at <input>:1:7
   thrown from: ../elaborate.cxx:1061
        source: probe process("ls").function("main") {}
                      ^

semantic error: cannot find executable '//ls'
   thrown from: ../tapsets.cxx:672
Comment 1 Frank Ch. Eigler 2016-05-01 17:50:23 UTC
This appears corrected with patches from Torsten.Polle@gmx.de.
It is necessary to use full path names for process probes (which will be resolved relative to the host machine's sysroot directory, and absolutely on the target).
Comment 2 Josh Stone 2016-05-06 23:40:13 UTC
(In reply to Frank Ch. Eigler from comment #1)
> It is necessary to use full path names for process probes

That's understandable when using a sysroot, but it's surprising that you can't use relative paths in the default case.  This is a breaking change I think we need to fix.

In particular, listing_mode.exp has a lot of regressions, for instance:

 stap -l 'process("./listing_mode").library("*liblisting_mode.so").function("*")'

... now returns nothing, and I bisected that failure to commit c30ff776c9e5.
Comment 3 Josh Stone 2016-05-23 16:45:41 UTC
PR20131 better describes the regression, so I'll close this one again and we can work there.