mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] replace 'hlt' by 'ud2' in i386/x32/x86_64 a_crash implementations
Date: Fri, 17 Apr 2015 12:44:01 -0400	[thread overview]
Message-ID: <20150417164401.GY6817@brightrain.aerifal.cx> (raw)
In-Reply-To: <alpine.LNX.2.11.1504171100550.3767@monopod.intra.ispras.ru>

On Fri, Apr 17, 2015 at 11:12:20AM +0300, Alexander Monakov wrote:
> On Fri, 17 Apr 2015, Rich Felker wrote:
> 
> > On Thu, Apr 16, 2015 at 08:58:59PM +0300, Alexander Monakov wrote:
> > > ---
> > > ud2 is also what GCC and Clang use to implement __builtin_trap()
> > > 
> > > ud2 causes SIGILL rather than SIGSEGV; SIGSEGV is more likely to have a custom
> > > signal handler installed
> > 
> > I've pondered instead using:
> > 
> > 	push $-1
> > 	mov $175,%eax
> > 	xor %ebx,%ebx
> > 	mov %esp,%ecx
> > 	int $128
> > 	hlt // or ud2?
> > 
> > This should be uncatchable but it's moderately larger. 
> 
> An argument in favor of plain hlt/ud2 is that registers and memory are
> preserved, in case someone will be analyzing the coredump.

That's a good point. The above could be fixed to preserve registers
with some minor added push/pop (simple pusha/popa on 32-bit)
before/after the syscall, but then it gets bigger.

Short of doing something like that, I think it's something of a flip
which of SIGSEGV vs SIGILL is better, and I don't feel like we have
enough information to make a good decision. There are reasons either
could be trapped -- some programs probably trap SIGILL to do runtime
cpudetection nonsense, and some programs just trap all fatal signals
to try to 'cleanup' or save state at exit. I'm not opposed to changing
to ud2 if it's better but I'd like to feel confident that it is better
rather than just guessing. Right now the main argument for ud2 is just
consistency with gcc (which isn't a bad reason in itself, but not very
strong either).

Rich


  reply	other threads:[~2015-04-17 16:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 17:58 Alexander Monakov
2015-04-17  5:55 ` Rich Felker
2015-04-17  8:12   ` Alexander Monakov
2015-04-17 16:44     ` Rich Felker [this message]
2015-04-17 18:48       ` Alexander Monakov
2015-04-17 20:23         ` 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=20150417164401.GY6817@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).