Subject: bug#53136: 28.0.90; segfault in lock_file

From: Po Lu <[email-masked]>
Date: Tue, 11 Jan 2022 08:51:25 +0800

Paul Eggert <[email-masked]> writes:

> On 1/9/22 04:03, Eli Zaretskii wrote:
>
>> Paul, could you please take a look?
>
> The problem (as Po deduced) seems to be that Haiku errno values are
> negative by default.

That was an unrelated problem.  This bug is on GNU/Linux, when running
under Valgrind.  (I was trying to find the GC bug from last month.)

> 1. It uses BE_USE_POSITIVE_POSIX_ERRORS but Haiku spells it
> B_USE_POSITIVE_POSIX_ERRORS.

I'll fix that.

> 2. There's no need to replace "if (err < 0)" with "if (err == -1 ||
> err == -2)", as this replacement is not needed given the "#if !defined
> HAIKU ..." stuff.

> 3. More importantly, I'm sure there are other places where Emacs
> assumes that errno values are positive. I doubt whether it's
> reasonable to expect Emacs developers to remember and work around this
> Haiku incompatibility, every time they call a function that sets errno
> or returns an errno value. Instead, we should arrange for Haiku builds
> to use positive errno values, they way errno behaves on GNU and other
> POSIX-compatible hosts. This should be a much more maintainable
> solution.

I would prefer for us to find and fix those instances manually, because
B_USE_POSITIVE_POSIX_ERRORS is some kind of stopgap measure for porting
POSIX utilities like sshfs, and prevents some other functionality from
working correctly (i.e. apparently it's an error to -ltracker with it
defined, so file dialogs won't work.)

Thanks.