Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#3102 closed bug (invalid)

diff reports "Unknown system error"

Reported by: bhaible Owned by: bonefish
Priority: normal Milestone: R1
Component: Applications/Command Line Tools Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: x86

Description

Diff, when called to compare two small files on BeFS, reports "Unknwon system error".

It could be a bug in diff, or in libroot. Since diff is from GNU and well-tested for a decade, my guess is that a system call in libroot returned a failure indicator but did not set errno.

Attachments (4)

haiku-diff-bug.png (22.5 KB) - added by bhaible 11 years ago.
screenshot
freadahead.c.bak (2.8 KB) - added by bhaible 11 years ago.
first argument file
freadahead.c (2.8 KB) - added by bhaible 11 years ago.
second argument file
haiku-diff-bug-strace.png (116.0 KB) - added by bhaible 11 years ago.
strace log

Download all attachments as: .zip

Change History (11)

Changed 11 years ago by bhaible

Attachment: haiku-diff-bug.png added

screenshot

comment:1 Changed 11 years ago by bonefish

Component: - GeneralApplications/Command Line Tools
Owner: changed from axeld to bonefish

I usually generate patches with diff in Haiku and haven't encountered this one yet. I just tried with a few small files and things worked as expected as well.

Can you attach the concerned files please. Also the output of an strace diff ... might be helpful.

Regarding GNU software, you're right in general. One problem we've encountered in several instances is that it sometimes implicitly assumes that error codes are positive values, which is not the case in Haiku (and BeOS, which far predates the time this requirement was added to the POSIX standard, BTW). I wouldn't be too surprised if this was another of such instances.

Changed 11 years ago by bhaible

Attachment: freadahead.c.bak added

first argument file

Changed 11 years ago by bhaible

Attachment: freadahead.c added

second argument file

Changed 11 years ago by bhaible

Attachment: haiku-diff-bug-strace.png added

strace log

comment:2 Changed 11 years ago by bhaible

Your guess about the negative errno value is right: According to the strace log, I had a typo in the filename ("freadhead.c", not "freadahead.c"), and the ENOENT errno was not properly converted to s text message like "No such file or directory", due to the private_strerror function in haiku/src/bin/diffutils/lib/error.c.

I will address this in the lib/error.c and lib/strerror.c from gnulib. But it would be good if you changed the errno values for POSIX compliance, in the medium term.

comment:3 in reply to:  2 ; Changed 11 years ago by anevilyak

Replying to bhaible:

I will address this in the lib/error.c and lib/strerror.c from gnulib. But it would be good if you changed the errno values for POSIX compliance, in the medium term.

That realistically can't be changed at this point without breaking compat with pretty much every existing BeOS app.

comment:4 Changed 11 years ago by scottmc

@Bruno: This related ticket might also be of interest to you: http://ports.haiku-files.org/ticket/70 Perhaps you can point us in the right direction on that one, I tried working around it a few months back but it was over my head. Might be related to #2696 and some of the missing functions?

comment:5 in reply to:  4 Changed 11 years ago by bonefish

Resolution: invalid
Status: newclosed

Replying to scottmc:

@Bruno: This related ticket might also be of interest to you: http://ports.haiku-files.org/ticket/70

This one is already obsolete. fpurge() and freading() have been implemented in Haiku since, and for freadahead() I did at least commit a patch -- though Bruno opted for a different solution.

comment:6 in reply to:  3 Changed 11 years ago by bonefish

Replying to anevilyak:

Replying to bhaible:

I will address this in the lib/error.c and lib/strerror.c from gnulib. But it would be good if you changed the errno values for POSIX compliance, in the medium term.

That realistically can't be changed at this point without breaking compat with pretty much every existing BeOS app.

Just to be clear: The BeOS API which Haiku inherits (and will keep and extend for the foreseeable future) requires error codes to be negative, so that e.g. a method's negative ssize_t return value does not only indicate that an error occurred, but does directly encode the error code. This concept is consequently used in the BeOS API and we can't change it without breaking pretty much all existing code.

comment:7 Changed 11 years ago by bhaible

The bug is in function private_strerror in haiku/src/bin/diffutils/lib/error.c. gnulib does not contain this code any more. So all that needs to be done to fix this issue, is to upgrade to haiku/src/bin/diffutils/ source code.

Note: See TracTickets for help on using tickets.