Skip to contentSkip to conversation

qemu: work around for "posix-aio-compat"

PATCH In review Michael S. Tsirkin 6 participants 20 messages Oct 8, 2009 – Oct 21, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu: work around for "posix-aio-compat"

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

For the benefit of whoever tries to debug this any deeper here's documentation on how to reproduce the issue to be saved in git logs (need to tweak paths obviously):

The test was done on FC11, 32 bit userspace, 64 bit kernel 2.6.31.

./configure --prefix=/scm/qemu-kvm-debug --target-list=x86_64-softmmu \
--enable-kvm
make -j 8 && make install
rm /scm/images/winxp-bisect.raw

/scm/qemu-kvm-debug/bin/qemu-img create -f raw \
/scm/images/winxp-bisect.raw 2G

/scm/qemu-kvm-debug/bin/qemu-system-x86_64 -enable-kvm -cdrom \
/home/mst/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso \
/scm/images/winxp-bisect.raw

Select format to NTFS.
---

OK, I'm out of time with this issue, let's apply a work-around until someone interested comes around?

 posix-aio-compat.c |   14 ++++++++++++--
posix-aio-compat.c +12 -2
index 400d898..4abbe3a 100644
@@ -301,6 +301,16 @@ static size_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
 static void *aio_thread(void *unused)
 {
     pid_t pid;
+    sigset_t set;
+
+    /* block all signals */
+    /* Should not be necessary as we should inherit mask
+     * from creating thread. However, without this,
+     * on FC11, using raw file, WinXP installation fails during disk format
+     * saying disk was damaged. pthread library bug?
+     * */
+    if (sigfillset(&set)) die("sigfillset");
+    if (pthread_sigmask(SIG_BLOCK, &set, NULL)) die("pthread_sigmask");
 
     pid = getpid();
 
@@ -371,11 +381,11 @@ static void spawn_thread(void)
 
     /* block all signals */
     if (sigfillset(&set)) die("sigfillset");
-    if (sigprocmask(SIG_SETMASK, &set, &oldset)) die("sigprocmask");
+    if (pthread_sigmask(SIG_SETMASK, &set, &oldset)) die("pthread_sigmask");
 
     thread_create(&thread_id, &attr, aio_thread, NULL);
 
-    if (sigprocmask(SIG_SETMASK, &oldset, NULL)) die("sigprocmask restore");
+    if (pthread_sigmask(SIG_SETMASK, &oldset, NULL)) die("pthread_sigmask restore");
 }
 
 static void qemu_paio_submit(struct qemu_paiocb *aiocb)
Signature · 1 line
1.6.5.rc2
#1 lore raw
Quoted 6 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

Quoted 8 lines

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

Thanks for the work you've put into it, i'll try to see how all of this works on my x86 machine.

[..snip..]

Signature · 1 line
mailto:[email protected]
#2 lore raw
Quoted 14 lines · malc
Quoted 12 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

Quoted 7 lines
Quoted 2 lines

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

Thanks for the work you've put into it, i'll try to see how all of this works on my x86 machine.

[..snip..]

Nope, still can not reproduce... So indeed it appears someone is needed, who:

a. Can reproduce
b. Cares

FWIW, in essence sigfillset is this:

# define __sigfillset(set) \

  (__extension__ ({ int __cnt = _SIGSET_NWORDS;                               \
                    sigset_t *__set = (set);                                  \
                    while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;          \
                    0; }))

So the thing that works for you can be replaced with some dummy loop or something, IOW not good enough, we need to understand the problem, and as mentioned above, i can not be of any help here, can't repro, sorry.

Signature · 1 line
mailto:[email protected]
#3 lore raw
Quoted 32 lines · malc
Quoted 14 lines · malc
Quoted 12 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

Quoted 7 lines
Quoted 2 lines

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

Thanks for the work you've put into it, i'll try to see how all of this works on my x86 machine.

[..snip..]

Nope, still can not reproduce... So indeed it appears someone is needed, who:

a. Can reproduce
b. Cares

FWIW, in essence sigfillset is this:

Quoted 8 lines

# define __sigfillset(set) \

  (__extension__ ({ int __cnt = _SIGSET_NWORDS;                               \
                    sigset_t *__set = (set);                                  \
                    while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;          \
                    0; }))

So the thing that works for you can be replaced with some dummy loop or something,

Exactly. I just did this:

sigset_t xset;

static void *aio_thread(void *unused)

{
    pid_t pid;
    sigset_t set;

    /* block all signals */
    /* Should not be necessary as we should inherit mask
     * from creating thread. However, without this,
     * on FC11, WinXP installation fails during disk format
     * saying disk was damaged. pthread library bug?
     * */
    memset(&set, 0, sizeof set);
    memcpy(&xset, &set, sizeof set);

and it also helps.

Quoted 6 lines

IOW not good enough, we need to understand the problem, and as mentioned above, i can not be of any help here, can't repro, sorry.

Signature · 1 line
mailto:[email protected]
#4 lore raw
Quoted 30 lines · Michael S. Tsirkin
Quoted 29 lines · malc
Quoted 14 lines · malc
Quoted 12 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

Quoted 7 lines
Quoted 2 lines

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

Thanks for the work you've put into it, i'll try to see how all of this works on my x86 machine.

[..snip..]

Nope, still can not reproduce... So indeed it appears someone is needed, who:

a. Can reproduce
b. Cares

[..snip..]

Quoted 22 lines
Quoted 3 lines

So the thing that works for you can be replaced with some dummy loop or something,

Exactly. I just did this:

sigset_t xset;

static void *aio_thread(void *unused)

{
    pid_t pid;
    sigset_t set;

    /* block all signals */
    /* Should not be necessary as we should inherit mask
     * from creating thread. However, without this,
     * on FC11, WinXP installation fails during disk format
     * saying disk was damaged. pthread library bug?
     * */
    memset(&set, 0, sizeof set);
    memcpy(&xset, &set, sizeof set);
Quoted 1 line

and it also helps.

Now question of the week is - why does pausing the work that aio_thread does helps things? Come to think of it - your machine (judging by -j 8) is a lot faster than anything i have in my vicinity, and that might be why i can not reproduce it...

Signature · 1 line
mailto:[email protected]
#5 lore raw
Quoted 57 lines · malc
Quoted 30 lines · Michael S. Tsirkin
Quoted 29 lines · malc
Quoted 14 lines · malc
Quoted 12 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

Quoted 7 lines
Quoted 2 lines

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

Thanks for the work you've put into it, i'll try to see how all of this works on my x86 machine.

[..snip..]

Nope, still can not reproduce... So indeed it appears someone is needed, who:

a. Can reproduce
b. Cares

[..snip..]

Quoted 22 lines
Quoted 3 lines

So the thing that works for you can be replaced with some dummy loop or something,

Exactly. I just did this:

sigset_t xset;

static void *aio_thread(void *unused)

{
    pid_t pid;
    sigset_t set;

    /* block all signals */
    /* Should not be necessary as we should inherit mask
     * from creating thread. However, without this,
     * on FC11, WinXP installation fails during disk format
     * saying disk was damaged. pthread library bug?
     * */
    memset(&set, 0, sizeof set);
    memcpy(&xset, &set, sizeof set);
Quoted 6 lines
Quoted 1 line

and it also helps.

Now question of the week is - why does pausing the work that aio_thread does helps things? Come to think of it - your machine (judging by -j 8) is a lot faster than anything i have in my vicinity, and that might be why i can not reproduce it...

No, I think it's just memory layout.
We have some memory corruption, using some stack space moves it about to a non-critical place.

Quoted 2 lines
Signature · 1 line
mailto:[email protected]
#6 lore raw

[Qemu-devel] Emulated network cards

Hi all!

I need a way to enumerate all emulated network cards. Is there any command line option or should I walk out source?

Regards

#7 lore raw

Re: [Qemu-devel] Emulated network cards

Quoted 4 lines · Natalia Portillo

Hi all!

I need a way to enumerate all emulated network cards. Is there any command line option or should I walk out source?

I'm not sure what you mean with "enumerate"; if you want to known which cards are compiled in on a given architecture:

qemu -net nic,model=?

Luca

#8 lore raw

Re: [Qemu-devel] Emulated network cards

That's exactly what I meant, thanks!

Quoted 12 lines · Luca Tettamanti
Quoted 4 lines · Natalia Portillo

Hi all!

I need a way to enumerate all emulated network cards. Is there any command line option or should I walk out source?

I'm not sure what you mean with "enumerate"; if you want to known which cards are compiled in on a given architecture:

qemu -net nic,model=?

Luca

#9 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · malc
Quoted 4 lines · Michael S. Tsirkin
Quoted 3 lines · malc
Quoted 1 line · malc

On Thu, 8 Oct 2009, Michael S. Tsirkin wrote:

[..snip..]

Quoted 4 lines

No, I think it's just memory layout.
We have some memory corruption, using some stack space moves it about to a non-critical place.

A theory that only you can proove.. Would be very interesting to see thec culprit regardless of what it is.

Signature · 1 line
mailto:[email protected]
#10 lore raw
In reply to Michael S. Tsirkin
Quoted 15 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

Quoted 8 lines

For the benefit of whoever tries to debug this any deeper here's documentation on how to reproduce the issue to be saved in git logs (need to tweak paths obviously):

The test was done on FC11, 32 bit userspace, 64 bit kernel 2.6.31.

Vanilla kernel from FC11 does the same btw.

Quoted 29 lines

./configure --prefix=/scm/qemu-kvm-debug --target-list=x86_64-softmmu \
--enable-kvm
make -j 8 && make install
rm /scm/images/winxp-bisect.raw

/scm/qemu-kvm-debug/bin/qemu-img create -f raw \
/scm/images/winxp-bisect.raw 2G

/scm/qemu-kvm-debug/bin/qemu-system-x86_64 -enable-kvm -cdrom \
/home/mst/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso \
/scm/images/winxp-bisect.raw

Select format to NTFS.
---

OK, I'm out of time with this issue, let's apply a work-around until someone interested comes around?

 posix-aio-compat.c |   14 ++++++++++++--
posix-aio-compat.c +0 -0
index 400d898..4abbe3a 100644
@@ -301,6 +301,16 @@ static size_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
 static void *aio_thread(void *unused)
 {
     pid_t pid;

posix-aio-compat.c static size_t handle_aiocb_rw(struct qemu_paiocb *aiocb) · line 313

Quoted 10 lines
posix-aio-compat.c +10 -0
+    sigset_t set;
+
+    /* block all signals */
+    /* Should not be necessary as we should inherit mask
+     * from creating thread. However, without this,
+     * on FC11, using raw file, WinXP installation fails during disk format
+     * saying disk was damaged. pthread library bug?
+     * */
+    if (sigfillset(&set)) die("sigfillset");
+    if (pthread_sigmask(SIG_BLOCK, &set, NULL)) die("pthread_sigmask");

By the way, things seem to work even when I comment out pthread_sigmask:
just sigfillset does it. Seems pretty wild.

Quoted 5 lines
posix-aio-compat.c +0 -0
     pid = getpid();
 
@@ -371,11 +381,11 @@ static void spawn_thread(void)
 

posix-aio-compat.c static void spawn_thread(void) · line 389

Quoted 10 lines
posix-aio-compat.c +2 -2
     /* block all signals */
     if (sigfillset(&set)) die("sigfillset");
-    if (sigprocmask(SIG_SETMASK, &set, &oldset)) die("sigprocmask");
+    if (pthread_sigmask(SIG_SETMASK, &set, &oldset)) die("pthread_sigmask");
 
     thread_create(&thread_id, &attr, aio_thread, NULL);
 
-    if (sigprocmask(SIG_SETMASK, &oldset, NULL)) die("sigprocmask restore");
+    if (pthread_sigmask(SIG_SETMASK, &oldset, NULL)) die("pthread_sigmask restore");
 }

As I said before, just this second hunk alone does not help.

Quoted 3 lines
posix-aio-compat.c +0 -0
 static void qemu_paio_submit(struct qemu_paiocb *aiocb)
Signature · 1 line
1.6.5.rc2
#11 lore raw
In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

Quoted 8 lines

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

FWIW, I just started hitting a boot hang with qemu.git and --enable-kvm on a Fedora 11 machine with a Fedora 11 guest.

I bisected it back to malc's commit, found this thread, applied Michael's patch and confirmed that it fixes the problem for me too.

Cheers,
Mark.

#12 lore raw
Quoted 13 lines · Mark McLoughlin
Quoted 12 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

Quoted 8 lines
Quoted 2 lines

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

FWIW, I just started hitting a boot hang with qemu.git and --enable-kvm on a Fedora 11 machine with a Fedora 11 guest.

I bisected it back to malc's commit, found this thread, applied Michael's patch and confirmed that it fixes the problem for me too.

If anybody can send me the output of compiling the "strange" file with and without the patch, both with "-fdump-tree-all -fdump-rtl-all -O2 --save-temps -g" flags, I could try debugging it in GCC.

It will be huge, so bz/gz/lzip it.

Paolo

#13 lore raw
Quoted 20 lines · Paolo Bonzini
Quoted 19 lines · Mark McLoughlin
Quoted 6 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

Quoted 8 lines

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

FWIW, I just started hitting a boot hang with qemu.git and --enable-kvm on a Fedora 11 machine with a Fedora 11 guest.

Quoted 8 lines
Quoted 2 lines

I bisected it back to malc's commit, found this thread, applied Michael's patch and confirmed that it fixes the problem for me too.

If anybody can send me the output of compiling the "strange" file with and without the patch, both with "-fdump-tree-all -fdump-rtl-all -O2 --save-temps -g" flags, I could try debugging it in GCC.

It will be huge, so bz/gz/lzip it.

I've uploaded them here:
http://www.kernel.org/pub/linux/kernel/people/mst/
you can't see them in mirrors yet but will be able to soon when kernel.org mirroring system catches them.

Quoted 1 line

Paolo

#14 lore raw
Quoted 28 lines · Michael S. Tsirkin
Quoted 27 lines · Paolo Bonzini
Quoted 13 lines · Mark McLoughlin
Quoted 12 lines · Michael S. Tsirkin

With commit ee3993069ff55fa6f1c64daf1e09963e340db8e4, "posix-aio-compat: avoid signal race when spawning a thread" winxp installation on a raw format file fails during disk format, with a message "your
disk may be damaged".

This commit moved signal mask from aio thread to creating thread. It turns out if we keep the mask in aio thread as well, the problem disappears. It should not be needed, but since this is harmless, let's keep it around until someone inclined to debug pthread library internals can check this issue.

Quoted 8 lines
Quoted 2 lines

While we are at it, convert sigprocmask to pthread_sigmask as per posix.

FWIW, I just started hitting a boot hang with qemu.git and --enable-kvm on a Fedora 11 machine with a Fedora 11 guest.

I bisected it back to malc's commit, found this thread, applied Michael's patch and confirmed that it fixes the problem for me too.

If anybody can send me the output of compiling the "strange" file with and without the patch, both with "-fdump-tree-all -fdump-rtl-all -O2 --save-temps -g" flags, I could try debugging it in GCC.

Quoted 6 lines
Quoted 1 line

It will be huge, so bz/gz/lzip it.

I've uploaded them here:
http://www.kernel.org/pub/linux/kernel/people/mst/
you can't see them in mirrors yet but will be able to soon when kernel.org mirroring system catches them.

ok, it's there now:
http://www.kernel.org/pub/linux/kernel/people/mst/posix-aio-corruption.tbz2
once you open this, you will see subdirectories "hang" and "nohang". the source file is also there, so that you can compare.

Quoted 2 lines
Quoted 2 lines

Paolo

#15 lore raw
In reply to Michael S. Tsirkin
Quoted 4 lines

I've uploaded them here:
http://www.kernel.org/pub/linux/kernel/people/mst/
you can't see them in mirrors yet but will be able to soon when kernel.org mirroring system catches them.

There is no difference in optimizations except that here:

        for (i = 0; i < aiocb->aio_niov && count; ++i) {

one of the two versions actually does "count && i < aiocb->aio_niov" due to hashing vagaries. This is irrelevant anyway. Same inlining, same loop optimization decisions, same everything else. So a GCC bug can be ruled out, IMHO.

The only difference, as someone already suspected, is the padding---the sigset is placed between the top of the frame and the other variables, which may hide an overrun. This is quite amazing for a function that has no arrays, but still is the only evidence.

I suggest trying to make the sigset_t static, since that generates exactly the same code as the "nohang" case, and exactly the same stack layout as the "hang" case. The next obvious step would be placing a watchpoint somewhere.

Cheers,

Paolo

#16 lore raw
Quoted 19 lines · Paolo Bonzini
Quoted 4 lines

I've uploaded them here:
http://www.kernel.org/pub/linux/kernel/people/mst/
you can't see them in mirrors yet but will be able to soon when kernel.org mirroring system catches them.

There is no difference in optimizations except that here:

        for (i = 0; i < aiocb->aio_niov && count; ++i) {

one of the two versions actually does "count && i < aiocb->aio_niov" due to hashing vagaries. This is irrelevant anyway. Same inlining, same loop optimization decisions, same everything else. So a GCC bug can be ruled out, IMHO.

The only difference, as someone already suspected, is the padding---the sigset is placed between the top of the frame and the other variables, which may hide an overrun. This is quite amazing for a function that has no arrays, but still is the only evidence.

Quoted 4 lines

I suggest trying to make the sigset_t static, since that generates exactly the same code as the "nohang" case, and exactly the same stack layout as the "hang" case. The next obvious step would be placing a watchpoint somewhere.

Yes, but where?

Quoted 3 lines

Cheers,

Paolo

#17 lore raw
Quoted 4 lines
Quoted 4 lines

I suggest trying to make the sigset_t static, since that generates exactly the same code as the "nohang" case, and exactly the same stack layout as the "hang" case.

(In case this wasn't clear: the sigfillset of a static sigset_t should hang, proving that it's stack layout that comes to the rescue).

Quoted 4 lines
Quoted 2 lines

The next obvious step would be placing a
watchpoint somewhere.

Yes, but where?

At every word of the sigset (using gdb commands to disable/enable the watchpoints around the sigfillset, you avoid spurious triggers). One of those words will be overwritten if an overrun would have smashed the stack. If it does not fire, s/sigfillset/sigemptyset/ in case it was writing 0xffffffff. If it still does not fire, dunno. :-(

Paolo

#18 lore raw
Quoted 8 lines · Paolo Bonzini
Quoted 4 lines
Quoted 4 lines

I suggest trying to make the sigset_t static, since that generates exactly the same code as the "nohang" case, and exactly the same stack layout as the "hang" case.

(In case this wasn't clear: the sigfillset of a static sigset_t should hang, proving that it's stack layout that comes to the rescue).

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

The next obvious step would be placing a
watchpoint somewhere.

Yes, but where?

At every word of the sigset (using gdb commands to disable/enable the watchpoints around the sigfillset, you avoid spurious triggers).

Not sure how do you mean. When would I enable the watchpoint?

Quoted 6 lines

One of
those words will be overwritten if an overrun would have smashed the stack. If it does not fire, s/sigfillset/sigemptyset/ in case it was writing 0xffffffff. If it still does not fire, dunno. :-(

Paolo

#19 lore raw
Quoted 5 lines
Quoted 3 lines

At every word of the sigset (using gdb commands to disable/enable the watchpoints around the sigfillset, you avoid spurious triggers).

Not sure how do you mean. When would I enable the watchpoint?

301 static void *aio_thread(void *unused)
302 {
303 pid_t pid;
304 static sigset_t set;
305
306 /* block all signals */
...
312 if (sigfillset(&set)) die("sigfillset");
....
315 pid = getpid();
316
317 while (1) {

b 312                    // sets bp 1
p ((long *)&set          // prints $1
watch $1[0]              // sets bp 2..9

watch $1[1]
watch $1[2]
watch $1[3]
watch $1[4]
watch $1[5]
watch $1[6]
watch $1[7] // only 1/4 of the sigset!

                         // stop earlier if it starts
                         // assigning non-hardware watchpoints
                         // try again with 8..15 if not enough
                         // up to $1[31]

commands 1 // don't break on next sigfillset
dis 2
dis 3
dis 4
dis 5
dis 6
dis 7
dis 8
dis 9
c // and continue
end
b 315 // sets bp 10
commands 10 // re-enable after sigfillset
ena 2
ena 3
ena 4
ena 5
ena 6
ena 7
ena 8
ena 9
c // run body of aio_thread
end
c // run into aio_thread

Paolo