Re: stack-trace: Use libasan as an alternative to libbacktrace

2024-07-18 Thread Bruno Haible
I did: > 2024-07-17 Bruno Haible > > stack-trace: Use libasan as an alternative to libbacktrace. > * m4/stack-trace.m4 (gl_STACK_TRACE_EARLY): As a second choice, use > libasan. However, on NetBSD 10.0, every program that links with libasan exits without even reaching main().

stdlib: Don't define print_stack_trace unconditionally

2024-07-18 Thread Bruno Haible
Yesterday I renamed _gl_pre_abort() to print_stack_trace(). But the latter is a symbol that could collide with some symbol defined by the application, and should therefore not be defined by gnulib's override unconditionally. This patch fixes that. 2024-07-18 Bruno Haible stdlib: Don'

doc: Document the stack-trace and abort-debug modules

2024-07-18 Thread Bruno Haible
The stack-trace and abort-debug modules are now in a state where they can be documented. Done as follows: 2024-07-18 Bruno Haible doc: Document the stack-trace and abort-debug modules. * doc/stack-trace.texi: New file. * doc/gnulib.texi (Particular Modules): Include it

Re: doc: Document the stack-trace and abort-debug modules

2024-07-18 Thread Paul Eggert
On 2024-07-18 05:25, Bruno Haible wrote: The stack-trace and abort-debug modules are now in a state where they can be documented. Done as follows: Thanks. Are these modules safe to use in signal handlers? I suspect that Emacs would need that, in order to use them. Either way, it should be doc

Re: stack-trace: Use libasan as an alternative to libbacktrace

2024-07-18 Thread Paul Eggert
On 2024-07-18 04:21, Bruno Haible wrote: on NetBSD 10.0, every program that links with libasan exits without even reaching main(). It merely prints "This sanitizer is not compatible with enabled ASLR" to standard error and exits with status 0 (yes, 0 !!!). If I understand things correctly a sim

[PATCH v1] xstrtol: 1 is not a valid base

2024-07-18 Thread Alejandro Colomar
If xstrtol() was being called with a base of 1, under some conditions it would invoke Undefined Behavior. Here's the code that would trigger UB: char *end; xstrtol(str, &end, 1, ...); // Let's ignore trailing args. The reason why this triggers UB is that since the following li

Re: [PATCH v1] xstrtol: 1 is not a valid base

2024-07-18 Thread Bruno Haible
Alejandro Colomar wrote: > If xstrtol() was being called with a base of 1, under some conditions it > would invoke Undefined Behavior. Yes, sure. A numeric base of 1 makes no sense, mathematically. Thanks for the patch; applied. Note that I disagree with the statement from https://github.com/voi

Re: stack-trace: Use libasan as an alternative to libbacktrace

2024-07-18 Thread Bruno Haible
Paul Eggert wrote: > If I understand things correctly a similar problem was also on FreeBSD > with PIE and the bug wasn't fixed until November of last year: > > https://github.com/llvm/llvm-project/commit/7440e4ed85aa992718d4b5ccd1c97724bc3bdd2c This issue does not affect the Gnulib 'stack-trace

Re: [PATCH v1] xstrtol: 1 is not a valid base

2024-07-18 Thread Alejandro Colomar
Hi Bruno, On Thu, Jul 18, 2024 at 08:06:07PM GMT, Bruno Haible wrote: > Alejandro Colomar wrote: > > If xstrtol() was being called with a base of 1, under some conditions it > > would invoke Undefined Behavior. > > Yes, sure. A numeric base of 1 makes no sense, mathematically. > > Thanks for the

Re: stack-trace: Use libasan as an alternative to libbacktrace

2024-07-18 Thread Bruno Haible
Paul Eggert wrote: > If I understand things correctly a similar problem was also on FreeBSD > with PIE and the bug wasn't fixed until November of last year: > > https://github.com/llvm/llvm-project/commit/7440e4ed85aa992718d4b5ccd1c97724bc3bdd2c Btw, I don't know why they do this. For the purpos

[PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
strtol(3) has a limited set of possible states: - The base was invalid. - return 0 - errno = EINVAL - endp is not set We cover this case with the assure() call, before strtol(3). - No conversion was performed. - return 0 - errno may be EINVAL, or may be unset. - *endp

Re: doc: Document the stack-trace and abort-debug modules

2024-07-18 Thread Bruno Haible
Paul Eggert wrote: > > The stack-trace and abort-debug modules are now in a state where they > > can be documented. Done as follows: > > Thanks. Are these modules safe to use in signal handlers? No, they aren't. Find attached the log of 'ltrace gltestst/test-stack-trace'. While libbacktrace care

abort-debug: Don't assume that signal SIGABRT is unmasked and unhandled

2024-07-18 Thread Bruno Haible
Reading the man page of abort(), I see that it deals with situations where SIGABRT is masked (via sigprocmask) or has a handler installed. The override needs to have the same behaviour. 2024-07-18 Bruno Haible abort-debug: Don't assume that signal SIGABRT is unmasked and unhandled.

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Bruno Haible
Hi Alejandro, > strtol(3) has a limited set of possible states: > ... > The condition '*endp != s && errno != 0 && errno != ERANGE' is > unreachable. The only errno possible if '*endp != s' is ERANGE. Such a statement can be true if you look at the standards (ISO C, POSIX). However, there's a d

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: > Hi Alejandro, Hi Bruno, > > strtol(3) has a limited set of possible states: > > ... > > The condition '*endp != s && errno != 0 && errno != ERANGE' is > > unreachable. The only errno possible if '*endp != s' is ERANGE. > > Such a sta

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
[CC -= Andrew, per explicit request] On Thu, Jul 18, 2024 at 11:25:11PM GMT, Alejandro Colomar wrote: > On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: > > Hi Alejandro, Hi Bruno, > > > strtol(3) has a limited set of possible states: > > > ... > > > The condition '*endp != s && errno

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Bruno Haible
Alejandro Colomar wrote: > > - Some systems return "wrong" errno values. Example: [1] > > - Some systems fail with ENOMEM when memory is tight. Who says that > > an implementation of strtol() cannot use malloc() ? Some implementations > > of strtod() do use malloc(). > > > > So, what y

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
Hi Bruno, On Fri, Jul 19, 2024 at 12:34:39AM GMT, Bruno Haible wrote: > Alejandro Colomar wrote: > > > - Some systems return "wrong" errno values. Example: [1] > > > - Some systems fail with ENOMEM when memory is tight. Who says that > > > an implementation of strtol() cannot use malloc()

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Alejandro Colomar
On Fri, Jul 19, 2024 at 12:14:19AM GMT, Alejandro Colomar wrote: > [CC -= Andrew, per explicit request] > > On Thu, Jul 18, 2024 at 11:25:11PM GMT, Alejandro Colomar wrote: > > On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: > > > Hi Alejandro, > > Hi Bruno, > > > > > strtol(3) has a

Re: [PATCH v1] xstrtol: Remove dead code

2024-07-18 Thread Andrew J. Hesford
Stop tagging me in your submissions. I have no involvement in any of this activity. -- Andrew J. Hesford a...@sideband.org [Mobile communication] > On Jul 18, 2024, at 5:25 PM, Alejandro Colomar wrote: > > On Thu, Jul 18, 2024 at 11:09:40PM GMT, Bruno Haible wrote: >> Hi Alejandro, > > Hi Br

Re: [PATCH v1] xstrtol: 1 is not a valid base

2024-07-18 Thread Paul Eggert
On 2024-07-18 12:53, Alejandro Colomar wrote: I think it'd be common to assume that unless specifically documented, you behave like POSIX's strtol(3), which produces defined behavior for a base of 1. Fair enough. I installed the attached Gnulib patch which addresses that point, along with the

xstrtod, xstrtold: Add documentation

2024-07-18 Thread Bruno Haible
Inspired by the discussion around xstrtol, I looked at xstrtod. I plan to commit this documentation, when savannah allows. And to look at the two FIXMEs regarding platform-dependent behaviour... 2024-07-18 Bruno Haible xstrtod, xstrtold: Add documentation. * lib/xstrtod.h (xs