On Okt 04 2021, Chet Ramey wrote: > On 10/4/21 4:34 AM, Andreas Schwab wrote: >> On Okt 04 2021, Julien Moutinho wrote: >> >>> - bash crashes inside valgrind too, >>> but apparently something different is happening >>> because it crashes even without systemd being involved: >>> >>> $ nix build .#bash5-with-bash-malloc >>> $ valgrind result/bin/bash --norc -c true >>>> ==307088== Memcheck, a memory error detector >>>> ==307088== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. >>>> ==307088== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright >>>> info >>>> ==307088== Command: result/bin/bash --norc -c true >>>> ==307088== >>>> ==307088== Invalid free() / delete / delete[] / realloc() >>>> ==307088== at 0x483F8E9: free (in >>>> /nix/store/7s7hzqaf5imxmpjlxh2n6fs7ixml98ya-valgrind-3.16.1/lib/valgrind/vgpreload_memcheck-amd64-linux.so) >>>> ==307088== by 0x47330F: xfree (xmalloc.c:150) >>>> ==307088== by 0x4644FA: unwind_frame_run_internal (unwind_prot.c:325) >>>> ==307088== by 0x4640B6: without_interrupts (unwind_prot.c:117) >>>> ==307088== by 0x464656: run_unwind_frame (unwind_prot.c:143) >>>> ==307088== by 0x479ACA: parse_and_execute (evalstring.c:523) >>>> ==307088== by 0x41C0A5: run_one_command (shell.c:1440) >>>> ==307088== by 0x41D6A1: main (shell.c:741) >>>> ==307088== Address 0x404be10 is in the brk data segment >>>> 0x4033000-0x4054fff >> >> Here is a patch: > > How does this fix the problem with valgrind? How does wrapping xfree in a > local function help?
Because xfree is a function-like macro, so taking the address does not work. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."