<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>188249</bug_id>
          
          <creation_ts>2007-08-09 18:01 0000</creation_ts>
          <short_desc>sys-apps/findutils-4.3.8: Segmentation fault (SIGSEGV)</short_desc>
          <delta_ts>2007-08-26 13:14:04 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>2007.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>Martin.vGagern@gmx.net</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          <cc>truedfx@gentoo.org</cc>
    
    <cc>xake@rymdraket.net</cc>

      

      
          <long_desc isprivate="0">
            <who>Martin.vGagern@gmx.net</who>
            <bug_when>2007-08-09 18:01:04 0000</bug_when>
            <thetext>I&apos;ve got here a strange case of find dying on me with SIGSEGV after printing one line of output. I&apos;ve located the following factors that seem to play a role:

- LC_MESSAGES=C and LANG=de_DE.utf8
- Compiled with -O2
- --prefix=/usr so it can find installed files
- find called with arguments -type f -ls
- at least two files in current directory

The problem does not occur if I set either LC_MESSAGES or LC_CTYPE to de_DE, or when I compile with -O0, or when I configure without arguments and don&apos;t install that build, or when I drop either argument to find.

I&apos;ve tryed to debug the issue. I traced the actual pagefault to an scenario where due to a wrong address a function pointer gets incremented instead of a simple integer counter. The address is four bytes off suggesting another off-by-one error, but I couldn&apos;t trace that. It&apos;s very difficult to trace the actual source of the error. Might possibly have security implications.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>Martin.vGagern@gmx.net</who>
            <bug_when>2007-08-09 18:01:51 0000</bug_when>
            <thetext>Created an attachment (id=127373)
emerge --info

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>Martin.vGagern@gmx.net</who>
            <bug_when>2007-08-09 19:31:54 0000</bug_when>
            <thetext>These might be steps to reproduce this issue:

tar xf /usr/portage/distfiles/findutils-4.3.8.tar.gz
cd findutils-4.3.8
./configure --prefix=/usr CFLAGS=&quot;-O2 -g&quot;
make
cd ..
mkdir sandbox
cd sandbox
touch a b
env -i LANG=de_DE.utf8 LC_MESSAGES=C ../findutils-4.3.8/find/find -type f -ls

Please tell mewhether these steps work for you as well, at least if your arch and gcc is the same I&apos;d expect they should, but I&apos;m not sure.

The expression will be parsed to a binary tree that looks like this in prefix notation: &quot;-a&quot; ( &quot;-a&quot; ( NULL, &quot;-type f&quot; ( NULL, NULL ) ), &quot;-ls&quot; ( NULL, NULL ) )
You can get this from &quot;find -D tree -type f -ls&quot;. My primary breakpoint while debuggung this issue was apply_predicate. There you have a pointer p denoting the current predicate, and from its elements you can get the whole subtree.

I found out that after prrinting ./a the expression &quot;++(p-&gt;perf.successes);&quot; in apply_predicate used a wrong address and instead of incrementing that counter incremented pred_ls which is the first element of struct predicate. The problem is that the pointer p used to address this counter is stored in ebx in apply_predicate, and somewhere in that register saving stuff I got lost.

Next I tried the other direction, to find out in what way the factors described above influence the problem. I ltraced two calls and replaced all hexadecimal numbers (which includes all those addresses that change with each run) so they match. Diffing the result showed a difference in the setlocale result string, in one bsearch call which I don&apos;t understand yet and then the SIGSEGV itself caused by an fprintf(NULL, ...). So I guess it&apos;s going on somewhere in the library itself, perhaps somewhere where the results from localeconv are used.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>truedfx@gentoo.org</who>
            <bug_when>2007-08-09 19:52:42 0000</bug_when>
            <thetext>Could you please try editing lib/listfile.c and in the function list_file change modebuf&apos;s size from 11 to 12? strmode as provided by gnulib initialises elements 0 through 11, so a buffer of size 11 is insufficient. I&apos;m not sure this is what&apos;s causing your specific problem though.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>truedfx@gentoo.org</who>
            <bug_when>2007-08-09 19:54:00 0000</bug_when>
            <thetext>Created an attachment (id=127395)
findutils-4.3.8-overflow.patch

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>Martin.vGagern@gmx.net</who>
            <bug_when>2007-08-09 20:07:41 0000</bug_when>
            <thetext>Works here as well. Did you find the impact of my environment, or was I just unlucky enough to hit this, and there is no real connection?

How about this line &quot;modebuf[10] = &apos;\0&apos;;&quot;? In the gnulib sources in that tarball that character will always be a space, corresponding to the space added by the fprintf in list file. So right now it doesn&apos;t make a difference. I&apos;m not sure about the relation between findutils and gnulib, whether they will stay in touch and if not which one is more likely to introduce a + for files with ACLs.

Should this issue be reported upstream as well? Will you do so?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>truedfx@gentoo.org</who>
            <bug_when>2007-08-09 20:27:16 0000</bug_when>
            <thetext>(In reply to comment #5)
&gt; Works here as well.

I&apos;m assuming you mean it still doesn&apos;t work :)

&gt; Did you find the impact of my environment, or was I just
&gt; unlucky enough to hit this, and there is no real connection?

It&apos;s very likely that you were just unlucky enough to hit this.

&gt; How about this line &quot;modebuf[10] = &apos;\0&apos;;&quot;? In the gnulib sources in that
&gt; tarball that character will always be a space, corresponding to the space added
&gt; by the fprintf in list file. So right now it doesn&apos;t make a difference.

By calling strmode, an extra byte on the stack will be set to zero, which could with a specific compiler version and a specific optimisation level and specific versions of all used headers be an important byte. The problem is often enough something as simple as that, and as hard to trace as your own problem.

&gt; I&apos;m not
&gt; sure about the relation between findutils and gnulib, whether they will stay in
&gt; touch and if not which one is more likely to introduce a + for files with ACLs.
&gt; 
&gt; Should this issue be reported upstream as well?

If it is a bug in findutils, then yes, but it&apos;s good to rule out a rare bug in the compiler and other parts of the environment first.

&gt; Will you do so?

I&apos;m not one of the maintainers of the Gentoo findutils package (I just have an interest in it); normally, for system packages, the issue will be reported upstream if/when the bug can be confirmed.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>Martin.vGagern@gmx.net</who>
            <bug_when>2007-08-09 20:39:02 0000</bug_when>
            <thetext>(In reply to comment #6)
&gt; I&apos;m assuming you mean it still doesn&apos;t work :)

???
That patch works as it fixes my local build, and with that fix find works as it doesn&apos;t crash any more. So why would I mean it doesn&apos;t work?

&gt; If it is a bug in findutils, then yes, but it&apos;s good to rule out a rare bug in
&gt; the compiler and other parts of the environment first.

I guess we can be pretty sure that&apos;s a bug in findutils. Once you&apos;ve looked at it, it&apos;s pretty obvious that&apos;s going to break one day, and you only wonder why it didn&apos;t do so earlier.

&gt; I&apos;m not one of the maintainers of the Gentoo findutils package (I just have an
&gt; interest in it); normally, for system packages, the issue will be reported
&gt; upstream if/when the bug can be confirmed.

On the other hand, you found the solution (and pretty quick at that, considering how long I debugged that trying to write a better report. How did you do it?), so the honour of presenting that fix to the upstream devs should imho be yours. :-)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>truedfx@gentoo.org</who>
            <bug_when>2007-08-09 20:59:51 0000</bug_when>
            <thetext>I thought you were saying your findutils still segfaulted in the rest of your message, but I must have been misreading. I&apos;m glad it&apos;s working.

&gt; How did you do it?

I did little more than check how it ran when compiled with -fmudflap.

@base-system: I&apos;d really prefer it if one of you would contact upstream about this.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2007-08-25 15:19:23 0000</bug_when>
            <thetext>upstream has this fixed and ive merged that into 4.3.8-r1</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2007-08-26 13:14:04 0000</bug_when>
            <thetext>*** Bug 187241 has been marked as a duplicate of this bug. ***</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>127373</attachid>
            <date>2007-08-09 18:01 0000</date>
            <desc>emerge --info</desc>
            <filename>emerge.info</filename>
            <type>text/plain</type>
            <data encoding="base64">UG9ydGFnZSAyLjEuMy4zIChkZWZhdWx0LWxpbnV4L3g4Ni8yMDA3LjAvZGVza3RvcCwgZ2NjLTQu
MS4yLCBnbGliYy0yLjYtcjAsIDIuNi4yMi1nZW50b28tcjIgaTY4NikKPT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KU3lzdGVt
IHVuYW1lOiAyLjYuMjItZ2VudG9vLXIyIGk2ODYgSW50ZWwoUikgUGVudGl1bShSKSA0IENQVSAz
LjAwR0h6CkdlbnRvbyBCYXNlIFN5c3RlbSByZWxlYXNlIDEuMTIuMTAKVGltZXN0YW1wIG9mIHRy
ZWU6IFRodSwgMDkgQXVnIDIwMDcgMDg6NTA6MDEgKzAwMDAKZGlzdGNjIDIuMTguMyBpNjg2LXBj
LWxpbnV4LWdudSAocHJvdG9jb2xzIDEgYW5kIDIpIChkZWZhdWx0IHBvcnQgMzYzMikgW2Rpc2Fi
bGVkXQpkZXYtamF2YS9qYXZhLWNvbmZpZzogMS4zLjcsIDIuMC4zMy1yMQpkZXYtbGFuZy9weXRo
b246ICAgICAyLjMuNi1yMiwgMi40LjQtcjQKZGV2LXB5dGhvbi9weWNyeXB0bzogMi4wLjEtcjYK
c3lzLWFwcHMvc2FuZGJveDogICAgMS4yLjE4LjEKc3lzLWRldmVsL2F1dG9jb25mOiAgMi4xMywg
Mi42MS1yMQpzeXMtZGV2ZWwvYXV0b21ha2U6ICAxLjRfcDYsIDEuNSwgMS42LjMsIDEuNy45LXIx
LCAxLjguNS1yMywgMS45LjYtcjIsIDEuMTAKc3lzLWRldmVsL2JpbnV0aWxzOiAgMi4xNy1yMQpz
eXMtZGV2ZWwvZ2NjLWNvbmZpZzogMS4zLjE2CnN5cy1kZXZlbC9saWJ0b29sOiAgIDEuNS4yNAp2
aXJ0dWFsL29zLWhlYWR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ZXMgdGV4dCIgTElOR1VB
Uz0iZW4gZGUiIExJUkNfREVWSUNFUz0iaGF1cHBhdWdlIiBNSVNETl9DQVJEUz0iYXZtZnJpdHoi
IFVTRVJMQU5EPSJHTlUiIFZJREVPX0NBUkRTPSJpODEwIGZiZGV2IHY0bCB2ZXNhIHZnYSIKVW5z
ZXQ6ICBDVEFSR0VULCBFTUVSR0VfREVGQVVMVF9PUFRTLCBJTlNUQUxMX01BU0ssIExDX0FMTCwg
TERGTEFHUywgUE9SVEFHRV9DT01QUkVTUywgUE9SVEFHRV9DT01QUkVTU19GTEFHUywgUE9SVEFH
RV9SU1lOQ19FWFRSQV9PUFRTCgo=
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>127395</attachid>
            <date>2007-08-09 19:54 0000</date>
            <desc>findutils-4.3.8-overflow.patch</desc>
            <filename>findutils-4.3.8-overflow.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGZpbmR1dGlscy00LjMuOC9saWIvbGlzdGZpbGUuYworKysgZmluZHV0aWxzLTQuMy44L2xp
Yi9saXN0ZmlsZS5jCkBAIC0yMDAsNyArMjAwLDcgQEAKIAkgICBpbnQgbGl0ZXJhbF9jb250cm9s
X2NoYXJzLAogCSAgIEZJTEUgKnN0cmVhbSkKIHsKLSAgY2hhciBtb2RlYnVmWzExXTsKKyAgY2hh
ciBtb2RlYnVmWzEyXTsKICAgc3RydWN0IHRtIGNvbnN0ICp3aGVuX2xvY2FsOwogICBjaGFyIGNv
bnN0ICp1c2VyX25hbWU7CiAgIGNoYXIgY29uc3QgKmdyb3VwX25hbWU7Cg==
</data>        

          </attachment>
    </bug>

</bugzilla>