cben has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Monks,
I'm trying to debug a program that uses xargs to feed a file of hex addresses (one per line) to addr2line. The output is piped to an open command to be read in and used later.
I didn't write the program but after days of debugging, I realize I need some help.
Here's the subroutine in question:
sub src_line_info { # see below for values for $addr2line, $exec, $cmd my ($addr2line, $exec) = @_; my ($cmd) = "xargs $addr2line -e $exec"; my ($tmpfile) = tmpnam(); my (@a2loutput); open(ADDRS, ">$tmpfile") or die "open($tmpfile) failed: $!\n"; foreach my $ra (@trace_addrs) { print ADDRS "$ra->[TADDR_ADDRESS]\n"; } close(ADDRS); $cmd = "$cmd < $tmpfile |"; open(LINES, $cmd) or die "open($cmd) failed: $!\n"; while (<LINES>) { chomp(); push(@a2loutput, [split(/:/, $_)]); } close(LINES); . . . }
Variable values:
================
src_line_info: $addr2line=/auto/stbu-tools/wrlinux/wrl6/wrlinux-6/laye +rs/binary-toolchain-4.8-39/bin/i686-wrs-linux-gnu-addr2line<br> src_line_info: $exec=/auto/pix-asa-image/essen/9.4.2.11/smp<br> src_line_info: $cmd to open for LINES=xargs -p /auto/stbu-tools/wrlinu +x/wrl6/wrlinux-6/layers/binary-toolchain-4.8-39/bin/i686-wrs-linux-gn +u-addr2line -e /auto/pix-asa-image/essen/9.4.2.11/smp < /tmp/fileAnma +9v |
/tmpfile example data:
======================
expected <LINES> output of:0x0000000002823a32<br> 0x00000000007254dd<br> 0x00000000017199f0<br> 0x00000000017230fc<br> 0x000000000282397b<br> 0x00000000007254dd<br> 0x00000000017199f0<br> 0x00000000017230fc<br> 0x0000000000c88e63<br> 0x0000000000c93f7d<br> 0x0000000000c87aba<br>
Actual output:/local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/data-plane/dispatch/ +../../Xpix/../infrastructure/mp-datastruct/mp_percore.h:163<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/data-plane/dispatch/ +dispatch_lb.c:1636</p> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/infrastructure/lina/ +linux/lina.c:1592<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/infrastructure/lina/ +linux/lina_mem.c:255<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/data-plane/dispatch/ +dispatch_lb.c:1272<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/data-plane/dispatch/ +dispatch_lb.c:1636<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/infrastructure/lina/ +linux/lina.c:1592<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/infrastructure/lina/ +linux/lina_mem.c:255<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/Xpix/ixgbe_drv/ixgbe +_drv.c:377<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/Xpix/ixgbe_drv/ixgbe +_vport.c:61<br> /local/builders/essen/9.4.2_fcs_throttle/9.4.2.11/Xpix/ixgbe_drv/ixgbe +_drv.c:3001<br>
sh: /sw/packages/findutils/4.1/bin/xargs: Permission denied
The problem seems to be that either the
"open(LINES, $cmd)"or
"while(<LINES>)"is returning the following error message:
"sh: /sw/packages/findutils/4.1/bin/xargs: Permission denied"I've verified that:
- addr2line is executable
- tmpfile is readable
- the $exec file is rwx
- xargs is -rwxr-xr-x. 1 4294967294 4294967294 64484 Oct 28 2003 /sw/packages/findutils/4.1/bin/xargs
- the open command error message is not output
- I can execute the command line in $cmd with out the "|" manually from the unix shell
I tried executing xargs with -p to make it prompt so I could see if there was a specific error message from the temp file that wasn't coming back, but it didn't work.
I've used different files to ultimately generate the tmpfile, so it isn't the tmpfile itself that is the problem.
I'm out of ideas. Any help is appreciated.
One final thing. This code is from a build tree and will be invoked mechanically by a tool, so I can't really modify it directly. I will have to find ways to modify the code it calls (addr2line/xargs versions, etc). But I can modify it to debug it and figure out what's going on if you have any ideas on that front.
Many thanks for taking a look!!
cben
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: xargs error using open cmd for output with redirected input file
by hippo (Archbishop) on Nov 30, 2016 at 08:33 UTC | |
by cben (Initiate) on Nov 30, 2016 at 21:03 UTC | |
|
Re: xargs error using open cmd for output with redirected input file (setuid)
by Anonymous Monk on Nov 30, 2016 at 01:19 UTC | |
by cben (Initiate) on Nov 30, 2016 at 21:27 UTC | |
by Anonymous Monk on Dec 01, 2016 at 20:15 UTC | |
|
Re: xargs error using open cmd for output with redirected input file
by Laurent_R (Canon) on Nov 30, 2016 at 07:26 UTC | |
by cben (Initiate) on Nov 30, 2016 at 21:30 UTC |