Opened 16 years ago

Closed 16 years ago

Last modified 16 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:
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 16 years ago.
screenshot
freadahead.c.bak (2.8 KB ) - added by bhaible 16 years ago.
first argument file
freadahead.c (2.8 KB ) - added by bhaible 16 years ago.
second argument file
haiku-diff-bug-strace.png (116.0 KB ) - added by bhaible 16 years ago.
strace log

Download all attachments as: .zip

Change History (11)

by bhaible, 16 years ago

Attachment: haiku-diff-bug.png added

screenshot

comment:1 by bonefish, 16 years ago

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.

by bhaible, 16 years ago

Attachment: freadahead.c.bak added

first argument file

by bhaible, 16 years ago

Attachment: freadahead.c added

second argument file

by bhaible, 16 years ago

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

strace log

comment:2 by bhaible, 16 years ago

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.

in reply to:  2 ; comment:3 by anevilyak, 16 years ago

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 by scottmc, 16 years ago

@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?

in reply to:  4 comment:5 by bonefish, 16 years ago

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.

in reply to:  3 comment:6 by bonefish, 16 years ago

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 by bhaible, 16 years ago

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.