strace seg with select and -ve nfds

Denys Vlasenko dvlasenk at
Fri Nov 8 11:27:18 UTC 2013

On 11/06/2013 01:06 AM, Dmitry V. Levin wrote:
> Looks like all FD_ISSET implementations just test the n-th bit in the
> array of long ints.  I've pushed a commit with yet another FD_ISSET
> implementation that hopefully does the same.
>> On the related note, how are we doing in "stracing 32-bit app
>> with 64-bit strace on a big-endian machine" case?
>> In that case, sizeof(long) is important...
>> I dread to think about that:(
> We cannot make things worse than they were since the beginning. :)

Testing each bit with FD_ISSET is silly in any case, so I attempted to fix
both "bit-endian wordsize bug" and performance problem in one go,
by introducing a next_set_bit() function which just gives us
a next bit's position.

It skips over entire zero bytes. By using bytes instead of words,
it can walk bytes in big-endian sequence suitable for current_wordsize
without the need of awkward code to access a runtime-variable-width word.

It also skips zero bytes even in not-fully zeroed words,
which may be a win on speed.

Run-tested, although I do not have the environment to reproduce
the bit-endian wordsize bug.

Dmitry, please review.

Patch #2 just syncs up select decoding in pathtrace.c with the main one.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.patch
Type: text/x-patch
Size: 4887 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.patch
Type: text/x-patch
Size: 1780 bytes
Desc: not available
URL: <>

More information about the Strace-devel mailing list