[Home]

Summary:ASTERISK-12219: build_tools/strip_nonapi 1.4/1.6 may run strip with -N as last argument
Reporter:Nik Soggia (nik soggia)Labels:
Date Opened:2008-06-18 11:00:43Date Closed:2008-06-19 11:20:50
Priority:MinorRegression?No
Status:Closed/CompleteComponents:General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:it happens on some old systems (mine is slackware 10.2), newer system are unlikely to be affected because today command lines can be longer than some time ago.

when the whole list of arguments generated by "sed" cannot fit in a single command execution, "xargs" will run "strip" a few times.
"-N" and its argument are not guaranteed to stay together because they are separated by spaces.

the bug can be reproduced with a bit of luck, replacing "xargs" with "xargs -s 1000" and decrementing "1000" by 5 until one execution ends with "-N" and the next one starts with the symbol name without the "-N" in front.

I solved the problem with this:
sed -i 's|/-N /|/--strip-symbol=/|g' build_tools/strip_nonapi
before running the top-level make.

with this workaround "xargs" still splits its stdin, but as long as symbols don't contain spaces the resulting command-line should be always correct.

I hope that this workaround is portable, if not, we may have to add a check such as:

if "${STRIP}" 2>&1 | grep -q -e --strip-symbol ; then
   echo you may use "--strip-symbol="
else
   echo you should use "-N "
fi

****** ADDITIONAL INFORMATION ******

I replaced "xargs" with "xargs echo" and here is a "make" output, I edited it for brevity. look at the last two lines:

/usr/bin/strip asterisk -N MD5Final [...] -N __rec_dleaf
/usr/bin/strip asterisk -N __rec_fd [...] -N el_getc
/usr/bin/strip asterisk -N el_gets [...] -N read_config_maps -N
/usr/bin/strip asterisk read_history -N readline [...] -N write_history
Comments:By: Tilghman Lesher (tilghman) 2008-06-18 14:54:42

Why not just use 'xargs -n 500' (or any even number)?

By: Nik Soggia (nik soggia) 2008-06-19 03:51:02

It will surely solve the problem, and it works on solaris too.

My xargs decided that the maximum command line lenght (including "echo strip asterisk") was 1024 bytes and split the work in four: 67, 63, 63, 51 symbols each run (asterisk 1.4.21).
To be on the safe side, the even number should be 40 or less. Strip would run 7 times, still much less than 244 times.

I was just looking if it was possible to preserve the ability of modern system with large limits on command line length to strip the unneeded symbols in just one go. But the very little speed gain of a single script run once at the end of the build is far less important than portability, and the long option of my workaround works only with GNU xargs.

By: Digium Subversion (svnbot) 2008-06-19 11:19:05

Repository: asterisk
Revision: 123909

U   branches/1.4/build_tools/strip_nonapi

------------------------------------------------------------------------
r123909 | tilghman | 2008-06-19 11:19:04 -0500 (Thu, 19 Jun 2008) | 5 lines

Only process 40 arguments (20 files) at once with xargs, because some older
shells may force xargs to separate on an odd boundary.
(Closes issue ASTERISK-12219)
Reported by Nik Soggia

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=123909

By: Digium Subversion (svnbot) 2008-06-19 11:19:50

Repository: asterisk
Revision: 123913

_U  trunk/
U   trunk/build_tools/strip_nonapi

------------------------------------------------------------------------
r123913 | tilghman | 2008-06-19 11:19:49 -0500 (Thu, 19 Jun 2008) | 13 lines

Merged revisions 123909 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r123909 | tilghman | 2008-06-19 11:26:03 -0500 (Thu, 19 Jun 2008) | 5 lines

Only process 40 arguments (20 files) at once with xargs, because some older
shells may force xargs to separate on an odd boundary.
(Closes issue ASTERISK-12219)
Reported by Nik Soggia

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=123913

By: Digium Subversion (svnbot) 2008-06-19 11:20:50

Repository: asterisk
Revision: 123918

_U  branches/1.6.0/
U   branches/1.6.0/build_tools/strip_nonapi

------------------------------------------------------------------------
r123918 | tilghman | 2008-06-19 11:20:49 -0500 (Thu, 19 Jun 2008) | 21 lines

Merged revisions 123913 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r123913 | tilghman | 2008-06-19 11:26:50 -0500 (Thu, 19 Jun 2008) | 13 lines

Merged revisions 123909 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r123909 | tilghman | 2008-06-19 11:26:03 -0500 (Thu, 19 Jun 2008) | 5 lines

Only process 40 arguments (20 files) at once with xargs, because some older
shells may force xargs to separate on an odd boundary.
(Closes issue ASTERISK-12219)
Reported by Nik Soggia

........

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=123918