GNU bug report logs - #21942
Files with incorrect file sizes

Previous Next

Package: diffutils;

Reported by: Stephan Müller <fruktopus <at> gmail.com>

Date: Tue, 17 Nov 2015 17:44:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21942 in the body.
You can then email your comments to 21942 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Tue, 17 Nov 2015 17:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephan Müller <fruktopus <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Tue, 17 Nov 2015 17:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephan Müller <fruktopus <at> gmail.com>
To: bug-diffutils <at> gnu.org
Subject: Files with incorrect file sizes
Date: Tue, 17 Nov 2015 12:44:08 +0100
Hi there,

recently I had to debug weird problem. Finally I figured it out.

Virtual file systems like /sys or /proc usually don't care about file
sizes. All files have a size of 0. This leads to difficulties as diff
sometimes looks for file sizes.

Say you do:

> $ cp /proc/cmdline my_cmdline
> $ diff /proc/cmdline my_cmdline ; echo $?
> 0      // ok, files don't differ
> $ diff --brief /proc/cmdline my_cmdline
> Files /proc/cmdline and mycmdline differ  

The --brief option triggers a binary compare, as we aren't interested
in the actual differences this makes sense. As a first step, file sizes
are compared (0 vs ~150) and the files are reported as different.

I am not sure how to fix this. I.e. are the files different or not? What
is the correct behavior. In any case --brief should have no influence on
the overall result! I see the following options (I prefer the 2nd):

1: Don't use file sizes in comparing. This is rather expensive but
would certainly fix it.

2: add a --use-file-sizes flag which enables decisions
based on file sizes. Without this flag, always look into the files.
And --brief should report, if the files differ because of their data or
size. That is 

> $ diff /proc/cmdline my_cmdline ; echo $?
> 0      // ok, files don't differ  

> $ diff --brief /proc/cmdline my_cmdline ; echo $0
> 0  

> $ diff --brief --use-file-sizes /proc/cmdline my_cmdline
> Files /proc/cmdline and mycmdline differ in file size  

3: Leave it at it is and add a warning in the man page. However that
would be very inconvenient.


   best, stephan




Information forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Fri, 20 Nov 2015 17:30:02 GMT) Full text and rfc822 format available.

Message #8 received at 21942 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Stephan Müller <fruktopus <at> gmail.com>
Cc: 21942 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: Files with incorrect file sizes
Date: Fri, 20 Nov 2015 18:28:37 +0100
On Tue, Nov 17, 2015 at 12:44 PM, Stephan Müller <fruktopus <at> gmail.com> wrote:
> recently I had to debug weird problem. Finally I figured it out.
>
> Virtual file systems like /sys or /proc usually don't care about file
> sizes. All files have a size of 0. This leads to difficulties as diff
> sometimes looks for file sizes.
>
> Say you do:
>
>> $ cp /proc/cmdline my_cmdline
>> $ diff /proc/cmdline my_cmdline ; echo $?
>> 0      // ok, files don't differ
>> $ diff --brief /proc/cmdline my_cmdline
>> Files /proc/cmdline and mycmdline differ
>
> The --brief option triggers a binary compare, as we aren't interested
> in the actual differences this makes sense. As a first step, file sizes
> are compared (0 vs ~150) and the files are reported as different.

thanks for the report.
What version of diffutils are you using?
I think this has been fixed for some time.
I was unable to reproduce with 2.8.1 nor with the latest built from git.
I.e., I created an empty file and used diff-2.8.1 to compare it with
the nominally-
zero-length /proc/cmdline file, and diff did the right thing.
Also, I ran stat to show st_size of each file is indeed 0:

  $ : > /tmp/k; /p/p/diffutils-2.8.1/bin/diff /proc/cmdline /tmp/k; \
     stat --format %s /proc/cmdline /tmp/k
  1d0
  < ro root=LABEL=...
  0
  0

In fact, I went ahead and built all available versions and tested them
like this:

  $ for i in /p/p/*/bin/diff; do p=diffutils-$i; echo $i; $i
/proc/cmdline /tmp/k > /dev/null && echo bad; done
  /p/p/diffutils-2.7/bin/diff
  /p/p/diffutils-2.8.1/bin/diff
  /p/p/diffutils-2.8/bin/diff
  /p/p/diffutils-2.9/bin/diff
  /p/p/diffutils-3.0/bin/diff
  /p/p/diffutils-3.1/bin/diff
  /p/p/diffutils-3.2/bin/diff
  /p/p/diffutils-3.3/bin/diff




Information forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Fri, 20 Nov 2015 20:08:01 GMT) Full text and rfc822 format available.

Message #11 received at 21942 <at> debbugs.gnu.org (full text, mbox):

From: Stephan Müller <fruktopus <at> gmail.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 21942 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: Files with incorrect file sizes
Date: Fri, 20 Nov 2015 21:06:54 +0100
Am Fri, 20 Nov 2015 18:28:37 +0100
schrieb Jim Meyering <jim <at> meyering.net>:

> On Tue, Nov 17, 2015 at 12:44 PM, Stephan Müller
> <fruktopus <at> gmail.com> wrote:
> > recently I had to debug weird problem. Finally I figured it out.
> >
> > Virtual file systems like /sys or /proc usually don't care about
> > file sizes. All files have a size of 0. This leads to difficulties
> > as diff sometimes looks for file sizes.
> >
> > Say you do:
> >
> >> $ cp /proc/cmdline my_cmdline
> >> $ diff /proc/cmdline my_cmdline ; echo $?
> >> 0      // ok, files don't differ
> >> $ diff --brief /proc/cmdline my_cmdline
> >> Files /proc/cmdline and mycmdline differ
> >
> > The --brief option triggers a binary compare, as we aren't
> > interested in the actual differences this makes sense. As a first
> > step, file sizes are compared (0 vs ~150) and the files are
> > reported as different.
> 
> thanks for the report.
> What version of diffutils are you using?
> I think this has been fixed for some time.
> I was unable to reproduce with 2.8.1 nor with the latest built from
> git. I.e., I created an empty file and used diff-2.8.1 to compare it
> with the nominally-
> zero-length /proc/cmdline file, and diff did the right thing.
> Also, I ran stat to show st_size of each file is indeed 0:
> 
>   $ : > /tmp/k; /p/p/diffutils-2.8.1/bin/diff /proc/cmdline /tmp/k; \
>      stat --format %s /proc/cmdline /tmp/k
>   1d0
>   < ro root=LABEL=...
>   0
>   0
> 
> In fact, I went ahead and built all available versions and tested them
> like this:
> 
>   $ for i in /p/p/*/bin/diff; do p=diffutils-$i; echo $i; $i
> /proc/cmdline /tmp/k > /dev/null && echo bad; done
>   /p/p/diffutils-2.7/bin/diff
>   /p/p/diffutils-2.8.1/bin/diff
>   /p/p/diffutils-2.8/bin/diff
>   /p/p/diffutils-2.9/bin/diff
>   /p/p/diffutils-3.0/bin/diff
>   /p/p/diffutils-3.1/bin/diff
>   /p/p/diffutils-3.2/bin/diff
>   /p/p/diffutils-3.3/bin/diff

Hi,

I am using v.3.3 of diffutils

$ diff -v 
diff (GNU diffutils) 3.3

but I think you misunderstood the problem. Sorry for being ambiguous. I
am not diffing against an empty file. That works well. The point is
procfs doesn't care about size, but 'normal' file systems do. So for
example on my system I have (after cp /proc/cmdline mycmdline)

$ stat --format %s /proc/cmdline mycmdline
0
140

The result of diffing /proc/cmdline against mycmdline depends on the
--brief flag.

STEPS TO REPRODUCE:

cp /proc/cmdline mycmdline
diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
1
diff /proc/cmdline mycmdline ; echo $?
0

EXPECTED RESULT:

cp /proc/cmdline mycmdline
diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
0
diff /proc/cmdline mycmdline ; echo $?
0

 ~stephan




Information forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Fri, 20 Nov 2015 22:14:02 GMT) Full text and rfc822 format available.

Message #14 received at 21942 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Stephan Müller <fruktopus <at> gmail.com>
Cc: 21942 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: Files with incorrect file sizes
Date: Fri, 20 Nov 2015 23:12:40 +0100
[Message part 1 (text/plain, inline)]
On Fri, Nov 20, 2015 at 9:06 PM, Stephan Müller <fruktopus <at> gmail.com> wrote:
> Am Fri, 20 Nov 2015 18:28:37 +0100
> schrieb Jim Meyering <jim <at> meyering.net>:
>
>> On Tue, Nov 17, 2015 at 12:44 PM, Stephan Müller
>> <fruktopus <at> gmail.com> wrote:
>> > recently I had to debug weird problem. Finally I figured it out.
>> >
>> > Virtual file systems like /sys or /proc usually don't care about
>> > file sizes. All files have a size of 0. This leads to difficulties
>> > as diff sometimes looks for file sizes.
>> >
>> > Say you do:
>> >
>> >> $ cp /proc/cmdline my_cmdline
>> >> $ diff /proc/cmdline my_cmdline ; echo $?
>> >> 0      // ok, files don't differ
>> >> $ diff --brief /proc/cmdline my_cmdline
>> >> Files /proc/cmdline and mycmdline differ
>> >
>> > The --brief option triggers a binary compare, as we aren't
>> > interested in the actual differences this makes sense. As a first
>> > step, file sizes are compared (0 vs ~150) and the files are
>> > reported as different.
>>
>> thanks for the report.
>> What version of diffutils are you using?
>> I think this has been fixed for some time.
>> I was unable to reproduce with 2.8.1 nor with the latest built from
>> git. I.e., I created an empty file and used diff-2.8.1 to compare it
>> with the nominally-
>> zero-length /proc/cmdline file, and diff did the right thing.
>> Also, I ran stat to show st_size of each file is indeed 0:
>>
>>   $ : > /tmp/k; /p/p/diffutils-2.8.1/bin/diff /proc/cmdline /tmp/k; \
>>      stat --format %s /proc/cmdline /tmp/k
>>   1d0
>>   < ro root=LABEL=...
>>   0
>>   0
>>
>> In fact, I went ahead and built all available versions and tested them
>> like this:
>>
>>   $ for i in /p/p/*/bin/diff; do p=diffutils-$i; echo $i; $i
>> /proc/cmdline /tmp/k > /dev/null && echo bad; done
>>   /p/p/diffutils-2.7/bin/diff
>>   /p/p/diffutils-2.8.1/bin/diff
>>   /p/p/diffutils-2.8/bin/diff
>>   /p/p/diffutils-2.9/bin/diff
>>   /p/p/diffutils-3.0/bin/diff
>>   /p/p/diffutils-3.1/bin/diff
>>   /p/p/diffutils-3.2/bin/diff
>>   /p/p/diffutils-3.3/bin/diff
>
> Hi,
>
> I am using v.3.3 of diffutils
>
> $ diff -v
> diff (GNU diffutils) 3.3
>
> but I think you misunderstood the problem. Sorry for being ambiguous. I
> am not diffing against an empty file. That works well. The point is
> procfs doesn't care about size, but 'normal' file systems do. So for
> example on my system I have (after cp /proc/cmdline mycmdline)
>
> $ stat --format %s /proc/cmdline mycmdline
> 0
> 140
>
> The result of diffing /proc/cmdline against mycmdline depends on the
> --brief flag.
>
> STEPS TO REPRODUCE:
>
> cp /proc/cmdline mycmdline
> diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
> 1
> diff /proc/cmdline mycmdline ; echo $?
> 0
>
> EXPECTED RESULT:
>
> cp /proc/cmdline mycmdline
> diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
> 0
> diff /proc/cmdline mycmdline ; echo $?
> 0

Oh, indeed. Thank you for clarifying. That feels like a bug.
Here's a knee-jerk patch that refrains from using the st_size-comparing
heuristic when either of the sizes is zero. This may well be wrong.
I have only barely tested the diff.c code path.
[st_size-is-zero.patch (text/x-patch, attachment)]

Information forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Fri, 20 Nov 2015 22:34:02 GMT) Full text and rfc822 format available.

Message #17 received at 21942 <at> debbugs.gnu.org (full text, mbox):

From: Stephan Müller <fruktopus <at> gmail.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 21942 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: Files with incorrect file sizes
Date: Fri, 20 Nov 2015 23:33:34 +0100
Am Fri, 20 Nov 2015 23:12:40 +0100
schrieb Jim Meyering <jim <at> meyering.net>:

> On Fri, Nov 20, 2015 at 9:06 PM, Stephan Müller <fruktopus <at> gmail.com>
> wrote:
> > Am Fri, 20 Nov 2015 18:28:37 +0100
> > schrieb Jim Meyering <jim <at> meyering.net>:
> >
> >> On Tue, Nov 17, 2015 at 12:44 PM, Stephan Müller
> >> <fruktopus <at> gmail.com> wrote:
> >> > recently I had to debug weird problem. Finally I figured it out.
> >> >
> >> > Virtual file systems like /sys or /proc usually don't care about
> >> > file sizes. All files have a size of 0. This leads to
> >> > difficulties as diff sometimes looks for file sizes.
> >> >
> >> > Say you do:
> >> >
> >> >> $ cp /proc/cmdline my_cmdline
> >> >> $ diff /proc/cmdline my_cmdline ; echo $?
> >> >> 0      // ok, files don't differ
> >> >> $ diff --brief /proc/cmdline my_cmdline
> >> >> Files /proc/cmdline and mycmdline differ
> >> >
> >> > The --brief option triggers a binary compare, as we aren't
> >> > interested in the actual differences this makes sense. As a first
> >> > step, file sizes are compared (0 vs ~150) and the files are
> >> > reported as different.
> >>
> >> thanks for the report.
> >> What version of diffutils are you using?
> >> I think this has been fixed for some time.
> >> I was unable to reproduce with 2.8.1 nor with the latest built from
> >> git. I.e., I created an empty file and used diff-2.8.1 to compare
> >> it with the nominally-
> >> zero-length /proc/cmdline file, and diff did the right thing.
> >> Also, I ran stat to show st_size of each file is indeed 0:
> >>
> >>   $ :
> >> > /tmp/k; /p/p/diffutils-2.8.1/bin/diff /proc/cmdline /tmp/k; \
> >> > stat --format %s /proc/cmdline /tmp/k
> >>   1d0
> >>   < ro root=LABEL=...
> >>   0
> >>   0
> >>
> >> In fact, I went ahead and built all available versions and tested
> >> them like this:
> >>
> >>   $ for i in /p/p/*/bin/diff; do p=diffutils-$i; echo $i; $i
> >> /proc/cmdline /tmp/k > /dev/null && echo bad; done
> >>   /p/p/diffutils-2.7/bin/diff
> >>   /p/p/diffutils-2.8.1/bin/diff
> >>   /p/p/diffutils-2.8/bin/diff
> >>   /p/p/diffutils-2.9/bin/diff
> >>   /p/p/diffutils-3.0/bin/diff
> >>   /p/p/diffutils-3.1/bin/diff
> >>   /p/p/diffutils-3.2/bin/diff
> >>   /p/p/diffutils-3.3/bin/diff
> >
> > Hi,
> >
> > I am using v.3.3 of diffutils
> >
> > $ diff -v
> > diff (GNU diffutils) 3.3
> >
> > but I think you misunderstood the problem. Sorry for being
> > ambiguous. I am not diffing against an empty file. That works well.
> > The point is procfs doesn't care about size, but 'normal' file
> > systems do. So for example on my system I have (after
> > cp /proc/cmdline mycmdline)
> >
> > $ stat --format %s /proc/cmdline mycmdline
> > 0
> > 140
> >
> > The result of diffing /proc/cmdline against mycmdline depends on the
> > --brief flag.
> >
> > STEPS TO REPRODUCE:
> >
> > cp /proc/cmdline mycmdline
> > diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
> > 1
> > diff /proc/cmdline mycmdline ; echo $?
> > 0
> >
> > EXPECTED RESULT:
> >
> > cp /proc/cmdline mycmdline
> > diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
> > 0
> > diff /proc/cmdline mycmdline ; echo $?
> > 0
> 
> Oh, indeed. Thank you for clarifying. That feels like a bug.
> Here's a knee-jerk patch that refrains from using the
> st_size-comparing heuristic when either of the sizes is zero. This
> may well be wrong. I have only barely tested the diff.c code path.

Thanks, that makes the problem at least (even) less unlikely. But if we
cant trust file sizes we're doomed. What do you think about a flag
controlling comparison by size and a notice if files differ by size.

I can craft a patch for this.

  ~s




Information forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Fri, 20 Nov 2015 22:41:02 GMT) Full text and rfc822 format available.

Message #20 received at 21942 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Stephan Müller <fruktopus <at> gmail.com>,
 Jim Meyering <jim <at> meyering.net>
Cc: 21942 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: bug#21942: Files with incorrect file
 sizes
Date: Fri, 20 Nov 2015 14:39:57 -0800
Stephan Müller wrote:
> What do you think about a flag

I'd rather avoid a flag. User-visible complexity has a cost, and we're better 
off keeping things simple.

Is there some easy way to tell whether we're on a file system like procfs that 
has the bug?  Perhaps we can have a list of known good file systems.  But this 
is lower priority than getting the bug fixed.




Information forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Sat, 21 Nov 2015 11:34:01 GMT) Full text and rfc822 format available.

Message #23 received at 21942 <at> debbugs.gnu.org (full text, mbox):

From: Stephan Müller <fruktopus <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: Jim Meyering <jim <at> meyering.net>, 21942 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: bug#21942: Files with incorrect file
 sizes
Date: Sat, 21 Nov 2015 12:33:12 +0100
Am Fri, 20 Nov 2015 14:39:57 -0800
schrieb Paul Eggert <eggert <at> cs.ucla.edu>:
> I'd rather avoid a flag. User-visible complexity has a cost, and
> we're better off keeping things simple.
> 
> Is there some easy way to tell whether we're on a file system like
> procfs that has the bug?  Perhaps we can have a list of known good
> file systems.  But this is lower priority than getting the bug fixed.

Ok, I agree. A flag is not optimal.

I did some reading but I think you cant tell if a file system has that
issue. I slightly more elaborate approach than just checking for file
size 0 (as Jim did) would be to actually try to read such a file and
see if you can get anything from it. If yes, than diff by looking into
the content.

However, still procfs or worse debugfs could report anything as size.
The only proper fix would be to ignore file sizes entirely.

 ~stephan




Information forwarded to bug-diffutils <at> gnu.org:
bug#21942; Package diffutils. (Sun, 06 Dec 2015 19:28:02 GMT) Full text and rfc822 format available.

Message #26 received at 21942 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Stephan Müller <fruktopus <at> gmail.com>
Cc: 21942 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: Files with incorrect file sizes
Date: Sun, 6 Dec 2015 11:27:20 -0800
[Message part 1 (text/plain, inline)]
On Fri, Nov 20, 2015 at 2:33 PM, Stephan Müller <fruktopus <at> gmail.com> wrote:
> Am Fri, 20 Nov 2015 23:12:40 +0100
> schrieb Jim Meyering <jim <at> meyering.net>:
>
>> On Fri, Nov 20, 2015 at 9:06 PM, Stephan Müller <fruktopus <at> gmail.com>
>> wrote:
>> > Am Fri, 20 Nov 2015 18:28:37 +0100
>> > schrieb Jim Meyering <jim <at> meyering.net>:
>> >
>> >> On Tue, Nov 17, 2015 at 12:44 PM, Stephan Müller
>> >> <fruktopus <at> gmail.com> wrote:
>> >> > recently I had to debug weird problem. Finally I figured it out.
>> >> >
>> >> > Virtual file systems like /sys or /proc usually don't care about
>> >> > file sizes. All files have a size of 0. This leads to
>> >> > difficulties as diff sometimes looks for file sizes.
>> >> >
>> >> > Say you do:
>> >> >
>> >> >> $ cp /proc/cmdline my_cmdline
>> >> >> $ diff /proc/cmdline my_cmdline ; echo $?
>> >> >> 0      // ok, files don't differ
>> >> >> $ diff --brief /proc/cmdline my_cmdline
>> >> >> Files /proc/cmdline and mycmdline differ
>> >> >
>> >> > The --brief option triggers a binary compare, as we aren't
>> >> > interested in the actual differences this makes sense. As a first
>> >> > step, file sizes are compared (0 vs ~150) and the files are
>> >> > reported as different.
>> >>
>> >> thanks for the report.
>> >> What version of diffutils are you using?
>> >> I think this has been fixed for some time.
>> >> I was unable to reproduce with 2.8.1 nor with the latest built from
>> >> git. I.e., I created an empty file and used diff-2.8.1 to compare
>> >> it with the nominally-
>> >> zero-length /proc/cmdline file, and diff did the right thing.
>> >> Also, I ran stat to show st_size of each file is indeed 0:
>> >>
>> >>   $ :
>> >> > /tmp/k; /p/p/diffutils-2.8.1/bin/diff /proc/cmdline /tmp/k; \
>> >> > stat --format %s /proc/cmdline /tmp/k
>> >>   1d0
>> >>   < ro root=LABEL=...
>> >>   0
>> >>   0
>> >>
>> >> In fact, I went ahead and built all available versions and tested
>> >> them like this:
>> >>
>> >>   $ for i in /p/p/*/bin/diff; do p=diffutils-$i; echo $i; $i
>> >> /proc/cmdline /tmp/k > /dev/null && echo bad; done
>> >>   /p/p/diffutils-2.7/bin/diff
>> >>   /p/p/diffutils-2.8.1/bin/diff
>> >>   /p/p/diffutils-2.8/bin/diff
>> >>   /p/p/diffutils-2.9/bin/diff
>> >>   /p/p/diffutils-3.0/bin/diff
>> >>   /p/p/diffutils-3.1/bin/diff
>> >>   /p/p/diffutils-3.2/bin/diff
>> >>   /p/p/diffutils-3.3/bin/diff
>> >
>> > Hi,
>> >
>> > I am using v.3.3 of diffutils
>> >
>> > $ diff -v
>> > diff (GNU diffutils) 3.3
>> >
>> > but I think you misunderstood the problem. Sorry for being
>> > ambiguous. I am not diffing against an empty file. That works well.
>> > The point is procfs doesn't care about size, but 'normal' file
>> > systems do. So for example on my system I have (after
>> > cp /proc/cmdline mycmdline)
>> >
>> > $ stat --format %s /proc/cmdline mycmdline
>> > 0
>> > 140
>> >
>> > The result of diffing /proc/cmdline against mycmdline depends on the
>> > --brief flag.
>> >
>> > STEPS TO REPRODUCE:
>> >
>> > cp /proc/cmdline mycmdline
>> > diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
>> > 1
>> > diff /proc/cmdline mycmdline ; echo $?
>> > 0
>> >
>> > EXPECTED RESULT:
>> >
>> > cp /proc/cmdline mycmdline
>> > diff --brief /proc/cmdline mycmdline > /dev/null ; echo ?$
>> > 0
>> > diff /proc/cmdline mycmdline ; echo $?
>> > 0
>>
>> Oh, indeed. Thank you for clarifying. That feels like a bug.
>> Here's a knee-jerk patch that refrains from using the
>> st_size-comparing heuristic when either of the sizes is zero. This
>> may well be wrong. I have only barely tested the diff.c code path.
>
> Thanks, that makes the problem at least (even) less unlikely. But if we
> cant trust file sizes we're doomed. What do you think about a flag
> controlling comparison by size and a notice if files differ by size.
>
> I can craft a patch for this.

Thank you, but I don't want to have to specify some new option to
avoid this misbehavior, so will push the attached patch shortly.
If someone finds a system for which a falsely reported stat.st_size
is nonzero, we can revisit this.
[0001-diff-brief-no-longer-mistakenly-reports-diff.-with-0.patch (text/x-patch, attachment)]

Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sun, 06 Dec 2015 19:41:01 GMT) Full text and rfc822 format available.

Notification sent to Stephan Müller <fruktopus <at> gmail.com>:
bug acknowledged by developer. (Sun, 06 Dec 2015 19:41:02 GMT) Full text and rfc822 format available.

Message #31 received at 21942-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Stephan Müller <fruktopus <at> gmail.com>
Cc: 21942-done <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#21942: Files with incorrect file sizes
Date: Sun, 6 Dec 2015 11:39:44 -0800
On Sun, Dec 6, 2015 at 11:27 AM, Jim Meyering <jim <at> meyering.net> wrote:
...
> Thank you, but I don't want to have to specify some new option to
> avoid this misbehavior, so will push the attached patch shortly.
> If someone finds a system for which a falsely reported stat.st_size
> is nonzero, we can revisit this.

Pushed with commit log changes and one fewer blank line in NEWS.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 04 Jan 2016 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 268 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.