8000 No more sys_errlist by faho · Pull Request #8234 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

No more sys_errlist#8234

Merged
faho merged 8 commits intofish-shell:masterfrom
faho:no-more-sys-errlist
Aug 20, 2021
Merged

No more sys_errlist#8234
faho merged 8 commits intofish-shell:masterfrom
faho:no-more-sys-errlist

Conversation

@faho
Copy link
Member
@faho faho commented Aug 19, 2021

Description

This removes safe_strerror and safe_perror (which uses the former internally), and replaces it with hardcoded error messages.

The impetus for this is that glibc actually removed sys_errlist and according to #7006 we can't use strerror_r either.

I looked up the used errno values I could find. It's possible these are incomplete, in which case we get more "Unknown error $errno" messages, but I don't think that should be a common thing, and on current glibc that's already all of the errors here (except for the exec errors that we already explained).

Fixes issue #4183.

Ideally I would like this to be included in 3.4.0, provided we can get enough testing.

TODOs:

  • [N/A] Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

faho added 3 commits August 19, 2021 15:44
This no longer works on new glibcs because they removed sys_errlist.

So just hardcode the relevant errno messages (and phrase them better).

Fixes fish-shell#4183.
This also calls safe_strerror, which isn't usable anymore on new
glibc.

It is also ridiculous since the errors are bad to begin with.

We only use it for setpgid and fork, and I doubt there's gonna be a
lot more added to it.
@faho faho added this to the fish 3.4.0 milestone Aug 19, 2021
@faho faho changed the title No more sys errlist No more sys_errlist Aug 19, 2021
break;
}
case ETXTBSY: {
FLOGF_SAFE(exec, "Failed to execute process '%s': File is currently open for writing.", actual_cmd);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I specifically made these messages not just the ones we get by default.

That's because "text file is busy" is among the worst error messages I have ever read, mostly because it has a 98% chance of appearing when the file is not a text file (in the sense any user cares about).

It's kinda like if an ice cream place told you "machine not fillable" when they're out of a certain flavor. Might be true in the technical sense, but so misleading that it might as well not be said, at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I would welcome more wording suggestions.

Copy link
Contributor
@krobelus krobelus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! The messages read nice.

}

case EACCES: {
FLOGF_SAFE(exec, "Failed to execute process '%s': The file could not be accessed.", actual_cmd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably run clang-format even if it makes this look slightly worse

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
@zanchey
Copy link
Member
zanchey commented Aug 20, 2021

We can use strerrordesc_np as a replacement for sys_errlist on platforms that support it (noted by @ridiculousfish), though that doesn't fix the issues of the poorly-written error descriptions.

@faho
Copy link
Member Author
faho commented Aug 20, 2021

We can use strerrordesc_np as a replacement for sys_errlist on platforms that support it

I don't know if strerrordesc_np provides any better guarantees than strerror_r ,which should be more widespread as it's in POSIX. We rejected that one in #7006.

faho added 4 commits August 20, 2021 15:52
Now unused too
Uh, yeah, EISDIR means it *is* a directory
@faho
Copy link
Member Author
faho commented Aug 20, 2021

Okay, tested on arch, alpine, FreeBSD, NetBSD, and Ubuntu and macOS on Github Actions.

It seems to compile everywhere and I can't find somewhere the errors are actually wrong, so I'm merging this now because it improves the status quo and I'd like to have it in 3.4.0.

More improvement is of course welcome!

@faho faho merged commit d4f7e25 into fish-shell:master Aug 20, 2021
@mqudsi
Copy link
Contributor
mqudsi commented Aug 20, 2021

I mean, you can’t beat error messages custom tailored to the faulting call - great work @faho.

@faho faho deleted the no-more-sys-errlist branch August 20, 2021 16:44
@zanchey
Copy link
Member
zanchey commented Aug 22, 2021

strerrordesc_np is specifically marked as async-signal-safe, but yeah, this is good

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0