mailing list of musl libc
 help / color / mirror / code / Atom feed
* diffutils crash in malloc
@ 2017-11-12 21:46 Tobias Koch
  2017-11-12 21:50 ` A. Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Tobias Koch @ 2017-11-12 21:46 UTC (permalink / raw)
  To: musl

Hi,

when I switched from musl 1.1.16 to 1.1.17 (and now 1.1.18) diff started to crash. The gdb backtrace shows, that this happens during memory allocation:

build@bootstrap(mipsel):~$ gdb /tools/bin/diff
...
Reading symbols from /tools/bin/diff...done.
(gdb) run a b
Starting program: /tools/bin/diff a b

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7d82bb7 in free (p=<optimized out>) at src/malloc/malloc.c:518
518             self->prev->next = self;
(gdb) bt
#0  0x00007ffff7d82bb7 in free (p=<optimized out>) at src/malloc/malloc.c:518
#1  0x00007ffff7d82ca5 in trim (self=self@entry=0x63c010, n=<optimized out>) at src/malloc/malloc.c:317
#2  0x00007ffff7d82f2d in malloc (n=<optimized out>, n@entry=4096) at src/malloc/malloc.c:364
#3  0x0000000000411809 in xmalloc (n=4096) at xmalloc.c:41
#4  0x0000000000408a78 in sip (current=0x7fffffffde30, skip_test=<optimized out>) at io.c:109
#5  0x0000000000408b6b in read_files (filevec=filevec@entry=0x7fffffffde30, pretend_binary=<optimized out>) at io.c:783
#6  0x0000000000404363 in diff_2_files (cmp=cmp@entry=0x7fffffffde30) at analyze.c:476
#7  0x0000000000406d10 in compare_files (parent=parent@entry=0x0, name0=<optimized out>, name1=<optimized out>) at diff.c:1433
#8  0x0000000000403870 in main (argc=<optimized out>, argv=<optimized out>) at diff.c:798

Here a and b are empty files, but this happens with other input, as well. diffutils' xmalloc looks fairly inconspicuous to me:

void *
xmalloc (size_t n)
{
  void *p = malloc (n);
  if (!p && n != 0)
    xalloc_die ();
  return p;
}

I understand this may very well be a problem in diff and not musl. But this is the exact same version of diffutils included with Debian Stretch and running the same under Valgrind compiled against glibc shows no problems. My wisdom ends here. Any clues how I can get to the bottom of this?

Tobias

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-11-13 20:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-12 21:46 diffutils crash in malloc Tobias Koch
2017-11-12 21:50 ` A. Wilcox
2017-11-12 22:02   ` Tobias Koch
2017-11-12 22:24     ` A. Wilcox
2017-11-12 22:38       ` Tobias Koch
2017-11-12 23:05         ` Rich Felker
2017-11-13 19:43           ` Tobias Koch
2017-11-13 20:09             ` Rich Felker
2017-11-13 20:43               ` Tobias Koch
2017-11-13 20:51                 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).