[Barrelfish-users] bug report about use -O0 compile skb

Kornilios Kourtis kornilios.kourtis at inf.ethz.ch
Tue Dec 18 12:24:58 CET 2012


Hi Jintang,

First of all, sorry for the late response... I can indeed reproduce what should
be the same bug. I'm not sure what causes it, but I thought I share some
information in case it rings a bell to somebody...

On Mon, Dec 03, 2012 at 12:45:22PM +0000, Wangjintang wrote:
> Hi,
> 
>   Use qemu in x86_64, if use -O0 to compile skb then will have error.
>   And use -O2 to compile will be ok.  Env: gcc version 4.4.5 (Debian
>   4.4.5-8) Linux amd64 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC
>   2012 x86_64 GNU/Linux
> 

[snip]
> kernel 0: user trap #13 in 'skb': IP 29312c656c75646f, error 0
> Can't deliver exception to thread: handler not set
> skb: unhandled trap (IRQ 13, error code 0x0) at IP 29312c656c75646f
[snip]

In my case I get:
Can't deliver exception to thread: handler not set
skb: unhandled page fault (error code 0x4) on 1007413d8 at IP 558f94
read page fault due to page not present, while in user mode

Which is in vfs_read:
279         assert(m->ops->read != NULL);
   0x0000000000558f8c <+43>:    mov    -0x10(%rbp),%rax
   0x0000000000558f90 <+47>:    mov    0x8(%rax),%rax
   0x0000000000558f94 <+51>:    mov    0x18(%rax),%rax
   0x0000000000558f98 <+55>:    test   %rax,%rax

Adding some printfs:
diff -r 9ff9bb5b3ea2 lib/vfs/vfs.c
--- a/lib/vfs/vfs.c     Mon Nov 26 12:31:50 2012 +0100
+++ b/lib/vfs/vfs.c     Tue Dec 18 12:19:56 2012 +0100
@@ -276,6 +276,8 @@
     struct vfs_handle *h = handle;
     struct vfs_mount *m = h->mount;
 
+    debug_printf("m->ops = %p\n", m->ops);
+    debug_printf("m->ops->read = %p\n", m->ops->read);
     assert(m->ops->read != NULL);
     return m->ops->read(m->st, handle, buffer, bytes, bytes_read);
 }

Reveals that the m->ops gets corrupted somehow:

...
skb.0: m->ops = 0x7000a0
skb.0: m->ops->read = 0x55dd68
skb.0: m->ops = 0x7000a0
skb.0: m->ops->read = 0x55dd68
skb.0: m->ops = 0x1007413c0
kernel 0: user page fault in 'skb': addr 1007413d8 IP 558fb0, error 0x4

It's difficult to tell when that happens, but it might be a bug somewhere in
skb, which would be difficult to hunt down.

I'm guessing you want to use  -O0 to enable debugging information? One possible
workaround would be to only set -O0 only for the program you intend to debug...

cheers,
Kornilios.

-- 
Kornilios Kourtis



More information about the Barrelfish-users mailing list