qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: qemu-devel@nongnu.org
Cc: Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] qemu-i386 segfaults running "hello world".
Date: Sat, 23 Jun 2007 01:31:19 -0400	[thread overview]
Message-ID: <200706230131.20408.rob@landley.net> (raw)
In-Reply-To: <467C578F.1090206@suse.de>

On Friday 22 June 2007 19:13:19 Alexander Graf wrote:
> Rob Landley wrote:
> > Ok, it's a more fundamental problem:
> >
> > landley@triolith:/sys$ qemu-i386
> > Segmentation fault (core dumped)
> >
> > Nothing to do with the program it's trying to run, it segfaults with no
> > arguments.
> >
> > Is anybody else seeing this?
> >
> > Rob
>
> agraf@mac:/vm/qemu-devel/patches/qemu> qemu-i386 ~/hello
> Hello world!
>
> Well it works for me. I usually see this segfault when trying to compile
> qemu with a gcc4. Try gcc3 and everything should be fine.

It's using gcc-3.4.  The one that comes with Ubuntu 7.04.  (Or at 
least ./configure said it had found gcc-3.4 during configuration, anyway.)

I ran the sucker under strace and it seems to be segfaulting right before it 
calls main().  I stuck an exit(1) at the start of main and it doesn't get to 
it, but it's after all the shared libraries are loaded:

> mprotect(0xb7f3f000, 4096, PROT_READ)   = 0
> mprotect(0x80000000, 548864, PROT_READ|PROT_WRITE) = 0
> mprotect(0x80000000, 548864, PROT_READ|PROT_EXEC) = 0
> munmap(0xb7f76000, 57255)               = 0
> set_tid_address(0xb7deca88)             = 4338
> sendto(-1210135920, umovestr: Input/output error
> 0xc, 3084914676,
> MSG_DONTWAIT|MSG_CONFIRM|MSG_FIN|MSG_NOSIGNAL|MSG_MORE|0xb7de0000,
> {sa_family=AF_DECnet, sa_data="\0\0\320=\0\0\r\0\0\0p\362\0\0"},
> 3217384328) = 0 rt_sigaction(SIGRTMIN, {0xb7df13f0, [], SA_SIGINFO}, NULL,
> 8) = 0
> rt_sigaction(SIGRT_1, {0xb7df1300, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
> rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
> getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
> uname({sys="Linux", node="triolith", ...}) = 0
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV (core dumped) +++
> Process 4338 detached

If I link "int main() {}" against -lm and -lrt I get the same set of calls up 
through the first mprotect.  (The next two mprotects are probably setting up 
other segments like bss that an empty program doesn't have.)  Then everything 
up through the uname() is the same...  And then it would call "main".

Right now I'm commenting out various global variable initializations because 
that's what comes to mind as "stuff that runs right before main()".

By the way, by commenting out this bit:

//const char interp[] __attribute__((section(".interp"))) 
= "/lib/ld-linux.so.2";

I made it go from "segmentation fault" to "illegal instruction" as the reason 
it dies.  Which is weird because there's no non-x86 toolchain the path, this 
is all stock Ubuntu stuff.  But oh well...

> Alex

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

  parent reply	other threads:[~2007-06-23  5:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-22 21:15 [Qemu-devel] qemu-i386 segfaults running "hello world" Rob Landley
2007-06-22 22:31 ` Rob Landley
2007-06-22 23:13   ` Alexander Graf
2007-06-22 23:27     ` andrzej zaborowski
2007-06-23  6:38       ` Rob Landley
2007-06-23  5:31     ` Rob Landley [this message]
2007-06-23  7:27       ` Alexander Graf
2007-06-24  5:40         ` Rob Landley
2007-06-23  7:41   ` Rob Landley
2007-06-23 11:00     ` Jens Axboe
2007-06-24  7:01       ` Rob Landley
2007-06-26 13:05         ` Jens Axboe
2007-06-23  9:50   ` Nigel Horne
2007-06-23 11:12   ` [Qemu-devel] [PATCH] " Stefan Weil
2007-06-24  7:36     ` Rob Landley
2007-07-02 15:02       ` Alexander Graf
2007-07-10 15:47         ` Rob Landley
2007-07-10 16:10           ` Andreas Färber

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=200706230131.20408.rob@landley.net \
    --to=rob@landley.net \
    --cc=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    /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.
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).