mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Cc: Support at Gcom <support@Gcom.com>
Subject: Re: Static linking of musl with code compiled using GNU header files
Date: Fri, 14 Mar 2014 20:22:09 -0400	[thread overview]
Message-ID: <20140315002209.GL184@brightrain.aerifal.cx> (raw)
In-Reply-To: <53236EF2.4030606@gcom.com>

On Fri, Mar 14, 2014 at 04:04:50PM -0500, David Grothe wrote:
> I built a shim module that defined all the undefined "__" routines
> that showed up in my link.  Then all my programs linked
> successfully.  But when I went to run one of my daemon processes it
> got a segv in the malloc code, as follows.
> 
> Program terminated with signal 11, Segmentation fault.
> #0  0x0811cd5d in unbin (c=0x9b53898, i=8) at src/malloc/malloc.c:242
> #1  0x0811d266 in malloc (n=112) at src/malloc/malloc.c:371
> #2  0x0804b3ce in ssd_malloc_fcn (nbytes=16, file=0x81348e6
> "../pi.c", linenr=2398) at ../pi.c:632
> #3  0x0804b597 in ssd_zalloc_fcn (nbytes=12, file=0x81348e6
> "../pi.c", linenr=2398) at ../pi.c:687
> #4  0x0804b5e2 in ssd_calloc_fcn (n_memb=1, memb_size=12,
> file=0x81348e6 "../pi.c", linenr=2398) at ../pi.c:696
> #5  0x0804ef18 in ss_setup_code_path (size=1024) at ../pi.c:2398
> #6  0x080548be in register_connections () at ../pi.c:5074
> #7  0x0805a2b8 in main (argc=2, argv=0xbfae15f4) at ../pi.c:7393
> (gdb) p *c
> $1 = {psize = 17, csize = 144, next = 0x81a3990, prev = 0x1}

The crashing line is:

        c->prev->next = c->next;

Based on this and your gdb print of *c, it looks like the chunk malloc
is trying to pull from the bin has had its contents (where it stores
its membership in the linked list of free chunks) clobbered, most
likely by your program. This is probably a use-after-free error. At
the very least, c->prev has been clobbered; it's also possible that
c->next was clobbered. You could try printing *c->next to see if it
looks like a valid chunk header (i can tell you if you send it to the
list).

Looking for the code that called free((void *)0x9b538a0) might be a
good way to track this down.

Rich


  parent reply	other threads:[~2014-03-15  0:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14 15:47 David Grothe
2014-03-14 16:09 ` Luca Barbato
2014-03-14 16:29 ` Szabolcs Nagy
2014-03-14 18:52   ` David Grothe
2014-03-14 19:25     ` Kurt H Maier
2014-03-14 19:35       ` David Grothe
2014-03-14 21:04     ` David Grothe
2014-03-14 21:37       ` John Spencer
2014-03-15  0:09         ` Rich Felker
2014-03-15  0:22       ` Rich Felker [this message]
2014-03-14 16:47 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140315002209.GL184@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    --cc=support@Gcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).