mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: Bracken Dawson <abdawson@gmail.com>, musl@lists.openwall.com
Subject: Re: Program with constructor function segfaults frequently with musl
Date: Thu, 15 Mar 2018 12:17:05 +0100	[thread overview]
Message-ID: <20180315111705.GV4418@port70.net> (raw)
In-Reply-To: <20180315110143.GU4418@port70.net>

* Szabolcs Nagy <nsz@port70.net> [2018-03-15 12:01:44 +0100]:
> * Bracken Dawson <abdawson@gmail.com> [2018-03-15 10:38:31 +0000]:
> > I have been having trouble getting a cgo program to run with musl, it has
> > been segfaulting frequently and with 'No stack' when run under gdb.
> > 
> > I have managed to reproduce such a failure in pure c with a very small
> > example:
> > 
> > ```
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <getopt.h>
> > 
> > __attribute__((constructor)) void enter_namespace(int argc, char *argv[]) {
> 
> the arguments passed to ctors are not part of the elf abi
> http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#init_fini

ah this does not explain the type signature, the right link is
http://www.sco.com/developers/gabi/latest/ch4.sheader.html#init_array

> (and it cannot really work for dynamically loaded libraries anyway:
> the application can arbitrarily clobber argv by that time)
> 
> glibc passes these arguments as an extension (the semantics
> for dlopened libraries is unclear), which happens to work
> since the calling convention of functions with no arguments
> allows this on all supported targets.
> 
> (note that there are security hardenning solutions that check
> the call site function signature against the callee and abort on
> mismatch and such extension would not work with that)
> 
> is this cgo that tries to capture argv in a ctor or some other
> c library? (in either case you should first try to solve it
> portably without depending on the glibc extension)


  reply	other threads:[~2018-03-15 11:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 10:38 Bracken Dawson
2018-03-15 11:01 ` Szabolcs Nagy
2018-03-15 11:17   ` Szabolcs Nagy [this message]
2018-03-15 11:28     ` Bracken Dawson
2018-03-15 12:12       ` Szabolcs Nagy
2018-03-15 15:35       ` Rich Felker
2018-03-15 20:34       ` Markus Wichmann

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=20180315111705.GV4418@port70.net \
    --to=nsz@port70.net \
    --cc=abdawson@gmail.com \
    --cc=musl@lists.openwall.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).