# qemu-system-x86_64 segfault

## darklich14

This could be tough to figure out what's wrong, judging from the surface level details. 

After referencing http://www.gentoo.org/doc/en/bugzilla-howto.xml#doc_chap2 I got the debugging symbols compiled into the code.

```
FEATURES="nostrip" emerge qemu-kvm
```

Then, I had to go back and get the code from the ebuild via http://www.gossamer-threads.com/lists/gentoo/user/136200

```
ebuild /usr/portage/app-emulation/qemu-kvm/qemu-kvm-0.13.0-r2.ebuild unpack
```

Then, I ran qemu-system-x86_64 through gdb:

```

localhost virttest # gdb qemu-system-x86_64

GNU gdb (Gentoo 7.2 p1) 7.2

Copyright (C) 2010 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "i686-pc-linux-gnu".

For bug reporting instructions, please see:

<http://bugs.gentoo.org/>...

Reading symbols from /usr/bin/qemu-system-x86_64...done.

(gdb) r

Starting program: /usr/bin/qemu-system-x86_64 

[Thread debugging using libthread_db enabled]

open /dev/kvm: No such file or directory

Could not initialize KVM, will disable KVM support

VNC server running on `127.0.0.1:5900'

Program received signal SIGSEGV, Segmentation fault.

0x081a8cd6 in gen_intermediate_code_internal (env=0x88ec6e0, tb=0xb49e762c) at /var/tmp/portage/app-emulation/qemu-kvm-0.13.0-r2/work/qemu-kvm-0.13.0/target-i386/translate.c:7841

7841           pc_ptr = disas_insn(dc, pc_ptr);

(gdb) l

7836               gen_opc_icount[lj] = num_insns;

7837           }

7838           if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))

7839               gen_io_start();

7840   

7841           pc_ptr = disas_insn(dc, pc_ptr);

7842           num_insns++;

7843           /* stop translation if indicated */

7844           if (dc->is_jmp)

7845               break;

(gdb) 

```

I'm not really sure where to go from here... I can't tell if I need to change something else about my system configuration, or if this is actually a bug in kvm. Anyone have ideas? Or other places to dig? I'm a software developer by trade, so this isn't an impossible technical challenge for me, but I don't know the culture or the philosophy on this one.

Here's some hardware info since it seems somewhat relevant:

```

localhost virttest # cat /proc/cpuinfo 

processor   : 0

vendor_id   : GenuineIntel

cpu family   : 15

model      : 0

model name   : Intel(R) Pentium(R) 4 CPU 1700MHz

stepping   : 10

cpu MHz      : 1694.876

cache size   : 256 KB

fdiv_bug   : no

hlt_bug      : no

f00f_bug   : no

coma_bug   : no

fpu      : yes

fpu_exception   : yes

cpuid level   : 2

wp      : yes

flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pebs bts

bogomips   : 3389.75

clflush size   : 64

cache_alignment   : 128

address sizes   : 36 bits physical, 32 bits virtual

power management:

```

----------

## darklich14

I just changed my make.conf to use -O0 instead of -O3 and rebuilt kvm and now it works.

----------

## Hu

Building with -O0 is a bad idea for general use.  It results in unoptimized binaries, and can degrade security since it prevents some _FORTIFY_SOURCE checks from working.  Does it work if you build with -O2?

----------

