Samuel Thibault writes: Hi!
> jann...@gnu.org, le ven. 15 nov. 2024 11:14:39 +0100, a ecrit: >> As a corollary, using this GDB I found that the statically built tar >> segfaults on the vtrying to issue the >> >> tar: Option --mtime: Treating date '@1' as 1970-01-01 01:00:01 >> >> warning: >> >> WARN ((0, 0, _("Option %s: Treating date '%s' as %s"), >> p->option, p->date, treated_as)); >> >> as it looks like, on the >> 274 vfprintf (stderr, message, args); >> >> call. I guess I'll try replacing that with a simple fprintf for the >> 64bit Hurd, > > That's however very worth investigating because something fishy is > at hand here, and better fix it here where it should be easy to > investigate, rather than in other places where it'd be way more tricky. > For a start, are p->option, p->date, and treated_as actually valid > strings? Yes (gdb) p *p $4 = {next = 0x0, ts = {tv_sec = 1, tv_nsec = 0}, rpl_option = 0x5b0132 "--mtime", date = 0x2000000033e0 "@1"} Everything looks fine. I'm using the attached patch to work around this and tested printing errors and warnings; everything works. This looks like a pretty simple place, but gnulib error reporting functions are a bit tricky: --8<---------------cut here---------------start------------->8--- Thread 4 hit Breakpoint 5, __error (status=0, errnum=0, message=0x5aff78 "Option %s: Treating date '%s' as %s") at error.c:274 274 vfprintf (stderr, message, args); (gdb) p stderr $6 = (FILE *) 0x608400 <_IO_2_1_stderr_> (gdb) p message $7 = 0x5aff78 "Option %s: Treating date '%s' as %s" (gdb) p args No symbol "args" in current context. (gdb) down Bottom (innermost) frame selected; you cannot go down. (gdb) up #1 0x000000000042897b in report_textual_dates (args=0x160fb40) at tar.c:1113 1113 WARN ((0, 0, _("Option %s: Treating date '%s' as %s"), (gdb) s __error_internal (status=0, errnum=0, message=0x5aff78 "Option %s: Treating date '%s' as %s", args=args@entry=0x160f9f8, mode_flags=mode_flags@entry=0) at error.c:242 242 res = mbsrtowcs (wmessage, &tmp, len, &st); (gdb) s 243 if (res != len) (gdb) s Thread 4 received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) bt #0 0x0000000000000000 in ?? () #1 0x00000000004f532d in __error_internal (status=0, errnum=0, message=0x5aff78 "Option %s: Treating date '%s' as %s", args=args@entry=0x160f9f8, mode_flags=mode_flags@entry=0) at error.c:243 #2 0x00000000004f5425 in __error (status=<optimized out>, errnum=<optimized out>, message=<optimized out>) at error.c:274 #3 0x000000000042897b in report_textual_dates (args=0x160fb40) at tar.c:1113 #4 0x000000000042c418 in decode_options (argc=10, argv=0x200000001270) at tar.c:2730 #5 0x000000000042c548 in main (argc=8, argv=0x160fcb8) at tar.c:2797 (gdb) up #1 0x00000000004f532d in __error_internal (status=0, errnum=0, message=0x5aff78 "Option %s: Treating date '%s' as %s", args=args@entry=0x160f9f8, mode_flags=mode_flags@entry=0) at error.c:243 243 if (res != len) (gdb) up #2 0x00000000004f5425 in __error (status=<optimized out>, errnum=<optimized out>, message=<optimized out>) at error.c:274 274 vfprintf (stderr, message, args); --8<---------------cut here---------------end--------------->8--- I don't understand how single-stepping on vfprintf (lne 274) brings me to line 234, which is inside "#if _LIBC" code. Greetings, Janneke
--- ./tar-1.34/lib/paxlib.h.orig 2024-11-15 11:47:57.340427845 +0100 +++ ./tar-1.34/lib/paxlib.h 2024-11-15 12:13:30.554724056 +0100 @@ -42,6 +42,17 @@ single argument of the form ((0, errno, _("FORMAT"), Args...)). errno is zero when the error is not being detected by the system. */ +#if __GNU__ && __x86_64__ + +#define PRINT_WARN(x, y, ...) fprintf (stderr, __VA_ARGS__) +#define WARN(Args) do { PRINT_WARN Args; } while (0) + +#define ERROR(Args) do { PRINT_WARN Args , exit (PAXEXIT_FAILURE); } while (0) +#define FATAL_ERROR(Args) do { PRINT_WARN Args , fatal_exit (); } while (0) +#define USAGE_ERROR(Args) do { PRINT_WARN Args , usage (PAXEXIT_FAILURE); } while (0) + +#else + #define WARN(Args) \ do { if (error_hook) error_hook (); error Args; } while (0) #define ERROR(Args) \ @@ -69,6 +80,8 @@ } \ while (0) +#endif + extern int exit_status; void pax_decode_mode (mode_t mode, char *string);
-- Janneke Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar® https://AvatarAcademy.com