All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X
@ 2013-02-01 12:14 Christopher Friedt
  2013-02-01 12:20 ` Christopher Friedt
  2013-02-01 18:01 ` Peter Maydell
  0 siblings, 2 replies; 5+ messages in thread
From: Christopher Friedt @ 2013-02-01 12:14 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

Hi folks,

I've been digging through a bunch of runtime errors in OS X. One of
them was an EXC_BAD_ACCESS (segfault) caused by some code in
main-loop.c that accessed uninitialized stack variables. Please see
the attached patch. The problem still exists in the master branch of
the git repository.

I've also been running into a failed assertion which causes SIGABRT

Assertion failed: (QLIST_EMPTY(&bs->tracked_requests)), function
bdrv_drain_all, file block.c, line 1220.

I haven't yet found out the root cause of it, but it sounds like
another struct that isn't properly zero'd. Will keep working on it.

C

[-- Attachment #2: qemu-1.3.0_to_gitmaster-fix-exc-bad-access-in-main-loop.patch --]
[-- Type: application/octet-stream, Size: 521 bytes --]

commit 253bf8ee69bad2e9f66b580b19250eb2dfe403d6
Author: Christopher Friedt <chrisfriedt@gmail.com>
Date:   Sat Jan 26 22:21:22 2013 -0500

    fix EXC_BAD_ACCESS error on Mac OS X

diff --git a/main-loop.c b/main-loop.c
index c87624e..1280869 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -40,7 +40,7 @@ static void sigfd_handler(void *opaque)
 {
     int fd = (intptr_t)opaque;
     struct qemu_signalfd_siginfo info;
-    struct sigaction action;
+    struct sigaction action = {};
     ssize_t len;
 
     while (1) {

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

* Re: [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X
  2013-02-01 12:14 [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X Christopher Friedt
@ 2013-02-01 12:20 ` Christopher Friedt
  2013-02-01 18:01 ` Peter Maydell
  1 sibling, 0 replies; 5+ messages in thread
From: Christopher Friedt @ 2013-02-01 12:20 UTC (permalink / raw)
  To: qemu-devel

Actually, disabling assertions, qemu appears to enter an infinite loop
where the above assertion fails. Boo.

On Fri, Feb 1, 2013 at 7:14 AM, Christopher Friedt
<chrisfriedt@gmail.com> wrote:
> Hi folks,
>
> I've been digging through a bunch of runtime errors in OS X. One of
> them was an EXC_BAD_ACCESS (segfault) caused by some code in
> main-loop.c that accessed uninitialized stack variables. Please see
> the attached patch. The problem still exists in the master branch of
> the git repository.
>
> I've also been running into a failed assertion which causes SIGABRT
>
> Assertion failed: (QLIST_EMPTY(&bs->tracked_requests)), function
> bdrv_drain_all, file block.c, line 1220.
>
> I haven't yet found out the root cause of it, but it sounds like
> another struct that isn't properly zero'd. Will keep working on it.
>
> C

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

* Re: [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X
  2013-02-01 12:14 [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X Christopher Friedt
  2013-02-01 12:20 ` Christopher Friedt
@ 2013-02-01 18:01 ` Peter Maydell
  2013-02-02  2:38   ` Christopher Friedt
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2013-02-01 18:01 UTC (permalink / raw)
  To: Christopher Friedt; +Cc: qemu-devel

On 1 February 2013 12:14, Christopher Friedt <chrisfriedt@gmail.com> wrote:
> I've been digging through a bunch of runtime errors in OS X. One of
> them was an EXC_BAD_ACCESS (segfault) caused by some code in
> main-loop.c that accessed uninitialized stack variables. Please see
> the attached patch. The problem still exists in the master branch of
> the git repository.

That struct sigaction is not used uninitialised -- we pass a
pointer to it as the third arg to sigaction(), which fills it
in for us.

OSX generally works for me, with some caveats:
 * current master doesn't compile because of a recent patch
   related to ffsl; this should be fixed soon I hope
 * running under gdb seems to cause failures which don't
   happen running not under a debugger. In particular it
   seems that sigwait() is broken by gdb (?!?) in a way that
   means it can return zero without setting *sig. A lack
   of error checking on the return value from sigaction()
   in sigfd_handler() means we then go off into the weeds.
 * for some reason sending qemu a SIGTERM doesn't cause us
   to terminate. I've had difficulty tracking down the issues
   due to the aforementioned tendency of macos gdb to bork
   signalhandling of the debuggee.

PS: you might like to read our guidelines for patch
submission; your patch failed several of them...
http://wiki.qemu.org/Contribute/SubmitAPatch

thanks
-- PMM

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

* Re: [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X
  2013-02-01 18:01 ` Peter Maydell
@ 2013-02-02  2:38   ` Christopher Friedt
  2013-02-02 11:07     ` Andreas Färber
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Friedt @ 2013-02-02  2:38 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

Hi Peter,

On Fri, Feb 1, 2013 at 1:01 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> OSX generally works for me, with some caveats:
>  * current master doesn't compile because of a recent patch
>    related to ffsl; this should be fixed soon I hope.

I'll have to check out master again. Currently I'm using 1.3.0, but
the ffsl issue
doesn't seem like it would be hard to fix at all.

>  * running under gdb seems to cause failures which don't
>    happen running not under a debugger. In particular it
>    seems that sigwait() is broken by gdb (?!?) in a way that
>    means it can return zero without setting *sig. A lack
>    of error checking on the return value from sigaction()
>    in sigfd_handler() means we then go off into the weeds.

Funny that you mention Mac OS X gdb, because I only ever did see a
segfault when I was debugging. I'm glad I wasn't the only one seeing
something unexpected. I'm sure Apple just markets that as a feature.

>  * for some reason sending qemu a SIGTERM doesn't cause us
>    to terminate. I've had difficulty tracking down the issues
>    due to the aforementioned tendency of macos gdb to bork
>    signalhandling of the debuggee.

Yea, SIGKILL seems to work well though ;-)

> PS: you might like to read our guidelines for patch
> submission; your patch failed several of them...
> http://wiki.qemu.org/Contribute/SubmitAPatch

I believe it - I posted it quickly before running out the door this morning.

Is there a more-or-less reliable build that's working for Mac?

C

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

* Re: [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X
  2013-02-02  2:38   ` Christopher Friedt
@ 2013-02-02 11:07     ` Andreas Färber
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2013-02-02 11:07 UTC (permalink / raw)
  To: Christopher Friedt; +Cc: Peter Maydell, qemu-devel

Hi Christopher,

Am 02.02.2013 03:38, schrieb Christopher Friedt:
> On Fri, Feb 1, 2013 at 1:01 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> OSX generally works for me, with some caveats:
>>  * current master doesn't compile because of a recent patch
>>    related to ffsl; this should be fixed soon I hope.
> 
> I'll have to check out master again. Currently I'm using 1.3.0, but
> the ffsl issue
> doesn't seem like it would be hard to fix at all.
[...]
> Is there a more-or-less reliable build that's working for Mac?

Try my branch, it is building okay - master plus one patch currently:
git://repo.or.cz/qemu/afaerber.git macosx
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/macosx

Regards,
Andreas

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

end of thread, other threads:[~2013-02-02 11:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-01 12:14 [Qemu-devel] patch to fix EXC_BAD_ACCESS on Mac OS X Christopher Friedt
2013-02-01 12:20 ` Christopher Friedt
2013-02-01 18:01 ` Peter Maydell
2013-02-02  2:38   ` Christopher Friedt
2013-02-02 11:07     ` Andreas Färber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.