<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>649</bug_id>
          
          <creation_ts>2011-01-07 10:26:04 +0000</creation_ts>
          <short_desc>QEMU Segfaults with nographic option</short_desc>
          <delta_ts>2011-03-31 05:19:46 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>Meta-yocto</product>
          <component>meta-yocto</component>
          <version>0.9</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>High</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>1.0 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Hatle">mark.hatle</reporter>
          <assigned_to name="Edwin Zhai">edwin.zhai</assigned_to>
          <cc>jessica.zhang</cc>
    
    <cc>julie.n.fleischer</cc>
    
    <cc>kevin.tian</cc>
    
    <cc>matias.sundman</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>scott.a.garman</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>11435</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-01-07 10:26:04 +0000</bug_when>
    <thetext>When the nographic option is selected I receive a segfault.  I believe this is occurring when the system attempts to startup the graphic console:

 (Note this is not mips specific, I get the same error on x86 and ppc)

poky-qemu qemumips nographic


Running qemu-system-mips...
/home/mhatle/git/poky/build/tmp/sysroots/x86_64-linux/usr/bin/qemu-system-mips -kernel /home/mhatle/git/poky/build/tmp/deploy/images/vmlinux-qemumips.bin -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=no,downscript=no -M malta -hda /home/mhatle/git/poky/build/tmp/deploy/images/poky-image-sato-qemumips.ext3 -no-reboot -vga cirrus -show-cursor -usb -usbdevice wacom-tablet -no-reboot -nographic --append &quot;root=/dev/hda console=ttyS0 console=tty ip=192.168.7.2::192.168.7.1:255.255.255.0 mem=128M &quot;
Linux version 2.6.37-rc8-yocto-standard+ (mhatle@msp-mhatle-lx2) (gcc version 4.5.1 (GCC) ) #1 PREEMPT Fri Jan 7 10:21:15 CST 2011
bootconsole [early0] enabled
CPU revision is: 00019300 (MIPS 24Kc)
FPU revision is: 00000000
Determined physical RAM map:
...

ide1 at 0x170-0x177,0x376 on irq 15
ide_generic: please use &quot;probe_mask=0x3f&quot; module parameter for probing all legacy ISA IDE ports
ide-gd driver 1.18
hda: max request size: 512KiB
hda: 1080586 sectors (553 MB) w/256KiB Cache, CHS=1072/255/63
hda: cache flushes supported
/home/mhatle/git/poky/scripts/poky-qemu-internal: line 449: 29535 Segmentation fault      (core dumped) $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append &quot;$KERNCMDLINE $SCRIPT_KERNEL_OPT&quot;
Set &apos;tap0&apos; nonpersistent
Releasing lockfile of preconfigured tap device &apos;tap0&apos;


In the initial setup the -vga cirrus is still enable, even with the -nographic option could this be part of the problem?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11455</commentid>
    <comment_count>1</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-01-11 23:45:58 +0000</bug_when>
    <thetext>Mark,
I can&apos;t reproduce this bug with commit 4b055ed in poky master on ubuntu. Generaly speaking, &quot;-vga cirrus&quot; should be removed when specifying &quot;-nographic&quot;, but qemu should handle this well and treat &quot;nographic&quot; as higher priority, which is observed on my side.

Can you boot without &quot;nographic&quot;? If this is specific issue with &quot;nographic&quot;, and it&apos;s hard to reproduce on my side, is it possible to let me use your machine?

Thanks,
edwin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11457</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-01-12 08:04:27 +0000</bug_when>
    <thetext>I removed the GL pass-through patches:


-    file://qemu-git-qemugl-host.patch \
-    file://fix-nogl.patch \
-    file://qemugl-allow-glxcontext-release.patch \
-    file://init-info.patch \
-    file://enable-i386-linux-user.patch \
-    file://vmware-vga-fifo-rewind.patch \

and compiled with --disable-sdl.  After that the crash went away.  My host system has the nvidia graphics drivers installed on it.  So likely it was a combination of the nvidia graphics drivers, and QEMU still using graphics resources even when -nographics was enabled.

I believe this points to a bug in QEMU, that even when nographics is selected it attempts to initialize the OpenGL resources -- which triggers the incompatibility with the Nvidia drivers.  This may or may not be triggered b the -vga cirrus...

We do need to make sure there is a way to run QEMU without graphics being used at all, to avoid problems like this in the future.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11836</commentid>
    <comment_count>3</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-02-17 00:10:30 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; I removed the GL pass-through patches:
&gt; and compiled with --disable-sdl.  After that the crash went away.  My host
&gt; system has the nvidia graphics drivers installed on it.  So likely it was a
&gt; combination of the nvidia graphics drivers, and QEMU still using graphics
&gt; resources even when -nographics was enabled.

&gt; We do need to make sure there is a way to run QEMU without graphics being used
&gt; at all, to avoid problems like this in the future.

Mark,
As I can&apos;t reproduce it on my side, could you pls. retest it after upgrading qemu to 0.13?
If it still exist, could you pls. use gdb to located where the seg fault come from?

Only possible reason is that GL patch is not clean enough and touch display screen. 

In theory, it has nothing to do with nvidia hardware. If qemu runs well in normal, it should also with &quot;nographic&quot;. There is no difference regarding hardware resource access. But it&apos;s just my guess, need further investigation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11841</commentid>
    <comment_count>4</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-02-17 17:41:46 +0000</bug_when>
    <thetext>Mark,
Could you pls. help to provide more info after upgrading qemu?
Thanks,</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12074</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-02-24 10:46:22 +0000</bug_when>
    <thetext>With the latest version of Poky (master as of 2011-02-24), QEMU still segfaults..  

poky-qemu qemuppc nographic

...

 hda: unknown partition table
/home/mhatle/git/poky/scripts/poky-qemu-internal: line 449: 21531 Segmentation fault      (core dumped) $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append &quot;$KERNCMDLINE $SCRIPT_KERNEL_OPT&quot;

By applying the patch on the top of the poky-contrib mhatle/qemu branch -- and running with &quot;nographic&quot; as above, it does not crash.

This might be related to the automatic use of &quot;-enable-gl&quot; in the qemux86 and qemux86-64 configurations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12437</commentid>
    <comment_count>6</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-09 22:18:49 +0000</bug_when>
    <thetext>Mark,
I have tried latest nightly build, and made sure it works well with &quot;nographic&quot;. Can you try it also too see if this issue is machine related or build related?
Sorry for bother you again, but I need reproduce first then fix it:)

    HOWTO:
    1. download disk image
    http://autobuilder.pokylinux.org/nightly/20110305-4/machines/qemu/qemumips/poky-image-sato-qemumips-20110303092454.rootfs.ext3

    2. download mips kernel
    http://autobuilder.pokylinux.org/nightly/20110305-4/machines/qemu/qemumips/vmlinux-2.6.37+git1+e2737075b79e4fc682e41051cf1c0bc47a47d502_1+76f30ca447fd0f06e76d0cb4935b016a1440e23e-r16-qemumips-20110303091203.bin

    3. download native environment from 
http://git.pokylinux.org/cgit.cgi/poky-contrib/plain/poky-lsb.tar.bz2?h=gzhai/for_mark

    4. unpack it under /var/,
       cd poky-lsb/0.9+snapshot/
       source environment-setup-mips-poky-linux
       poky-qemu mips-kernel-name disk-image-name nographic</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12450</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-03-10 06:34:02 +0000</bug_when>
    <thetext>To cause the crash you need a computer with an NVIDIA video card, and the proprietary (binary) nvidia X and OpenGL drivers.

If you are unable to get to one, let me know and I&apos;ll attempt to get you access to a machine so you can reproduce the problem.

I have not yet tested the exact build you are mentioning below, however I did try the HEAD of bernard on Tuesday an experienced exactly the same problem as before.  Even with &quot;nographic&quot; being set (and also making sure that -enable-gl is not passed to qemu), it still crashes as QEMU starts.

The only way I could work around this was remove the custom QEMU OpenGL patches and disable the SDL library when building qemu.  (This is what the patch does at the top of mhatle/qemu.)

Somehow we need to completely avoid even initializing OpenGL if -enable-gl is not passed to QEMU.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12461</commentid>
    <comment_count>8</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-03-10 16:21:41 +0000</bug_when>
    <thetext>I have tried the steps you outlined, it still crashes:

hda: 556982 sectors (285 MB) w/256KiB Cache, CHS=552/255/63
hda: cache flushes supported
/opt/poky-lsb/0.9+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/poky-qemu-internal: line 442: 22879 Segmentation fault      (core dumped) $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append &quot;$KERNCMDLINE $SCRIPT_KERNEL_OPT&quot;
Set &apos;tap0&apos; nonpersistent
Releasing lockfile of preconfigured tap device &apos;tap0&apos;

unfortunately the core that was dumped is bad and all it tells me is that again, it&apos;s a segmentation fault.

The host system is a Fedora 13 system, with the binary Nvidia drivers installed: NVIDIA-Linux-x86_64-260.19.21.run

The video card is: 03:00.0 VGA compatible controller: nVidia Corporation G98 [Quadro NVS 295] (rev a1)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12539</commentid>
    <comment_count>9</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-13 18:50:31 +0000</bug_when>
    <thetext>Mark,
I can reproduce it. debug is on going...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12547</commentid>
    <comment_count>10</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2011-03-13 22:41:16 +0000</bug_when>
    <thetext>See also 698</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12662</commentid>
    <comment_count>11</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-15 18:44:30 +0000</bug_when>
    <thetext>Finally I found this bug is duplicated bug from 698, caused by nVidia GL
lib. As long as qemu is linked with nVidia GL lib, even upstream qemu,
there must be segfault regardless of &quot;-nographic&quot; setting. 

Possible root cause is: 1. nVidia GL lib provides some symbol override
generic one, and cause segfauls when calling these symbol. 2. The .init
section in nVidia GL lib dirty qemu&apos;s data structure and lead the final
segfault.
Kevin and I went through the related symbols, and excluded 1. So we
doubt .init section need some fix. 

Before it got fixed in nVidia GL lib, we can have 3 options:
1. Add some checks in qemu&apos;s configure, and remove &quot;-lGL&quot; if detecting
nVidia&apos;s GL lib installed. It cause trouble when building and running machine are different.
2. Use dlopen rather than &quot;-lGL&quot;, so we can avoid touching bogus GL lib
if specifying &quot;-nographic&quot; or no &quot;-enable-gl&quot;. By this way, we can turn of gl when running. But need change source code to access the lib symbol, which is a little bit tricky.
3. Document it as known issue, and ask end user don&apos;t use nVidia driver.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12667</commentid>
    <comment_count>12</comment_count>
    <who name="Kevin Tian">kevin.tian</who>
    <bug_when>2011-03-15 19:58:55 +0000</bug_when>
    <thetext>option 1 is not accepted since the build system could be different from the maching running Qemu.

option 2 has some risk. dlopen/dlsyms are not a very stable approach, and we need to wrap all the opengl calls which are not trivial. Some NVidia driver version even overwrites dlsyms with its own version to cause trouble (http://www.nvnews.net/vbulletin/showthread.php?p=2070826). So it also needs careful test to ensure it not blocking other things when making slightly better in this nv case.

option 3 is possibly the choice we can do now for 1.0, given the limited time and the risk from option 2. User could fall back to default xorg-x11 libgl driver to use Qemu, and we may address it in next point release

Edwin will continue post his progress of course to see whether we can have another less risky option</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12676</commentid>
    <comment_count>13</comment_count>
    <who name="Kevin Tian">kevin.tian</who>
    <bug_when>2011-03-15 23:04:45 +0000</bug_when>
    <thetext>Edwin and I got another alternative. We could use LD_PRELOAD=/usr/lib/libGL.so to make sure xorg libGL is used instead of nVidia version. dynamic loader (ld.so) binds the symbol in reverse order, while LD_PRELOAD adds specificed library in the head. This ensures xorg libGL taking effect, while user can still use proprietary nVidia driver for his other desktop activity.

We have tested that this approach basically works. Edwin will do more test and then add conditional check in poky-qemu script to make sure LD_PRELOADED prefixed only when nVidia proporietary driver is detected. Then it should have no impact to other build environment</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12678</commentid>
    <comment_count>14</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-15 23:53:29 +0000</bug_when>
    <thetext>Mark,
Can you have a look at where is the nVidia&apos;s libGL on your fedora system?
/usr/lib/nvidia-current/libGL.so.xxx, or /usr/lib64/nvidia-current/libGL.so.xxx?

I&apos;ll cook up a patch to skip nvidia&apos;s libGL if finding it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12681</commentid>
    <comment_count>15</comment_count>
    <who name="Scott Garman">scott.a.garman</who>
    <bug_when>2011-03-16 00:52:27 +0000</bug_when>
    <thetext>Edwin,

In case this is helpful, on my 64-bit Ubuntu 10.10 system, NVIDIA&apos;s libGL is in /usr/lib64/nvidia-current/libGL.so</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12685</commentid>
    <comment_count>16</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-16 01:41:18 +0000</bug_when>
    <thetext>Mark &amp; Scott,
I have pushed 2 patches @ the branch http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=gzhai/for_mark

Can you have a try to see if it can fix this issue?

Thanks,
edwin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12704</commentid>
    <comment_count>17</comment_count>
    <who name="Scott Garman">scott.a.garman</who>
    <bug_when>2011-03-16 10:49:09 +0000</bug_when>
    <thetext>Edwin,

This appears to fix the problem on my system. Nice work!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12712</commentid>
    <comment_count>18</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-03-16 17:43:44 +0000</bug_when>
    <thetext>I have verified on Fedora 13 that the nvidia software gets installed into simply /usr/lib64.


lrwxrwxrwx. 1 root root     10 Jan 21 10:54 /usr/lib64/libGL.so -&gt; libGL.so.1*
lrwxrwxrwx. 1 root root     18 Jan 21 10:54 /usr/lib64/libGL.so.1 -&gt; libGL.so.260.19.21*
-rwxr-xr-x. 1 root root 982536 Jan 21 10:54 /usr/lib64/libGL.so.260.19.21*

The system version is removed, it would have been &quot;/usr/lib64/libGL.so.1.2&quot;.

You might be able to detect it though by looking for:

libnvidia-cfg.so                 libnvidia-cfg.so.260.19.21       libnvidia-glcore.so.260.19.21
libnvidia-cfg.so.1               libnvidia-compiler.so.260.19.21  libnvidia-tls.so.260.19.21

this libGL.so.260.19.21 has internal dependencies on:

 0x0000000000000001 (NEEDED)             Shared library: [libnvidia-tls.so.260.19.21]
 0x0000000000000001 (NEEDED)             Shared library: [libnvidia-glcore.so.260.19.21]

That is likely a clue as well.

My suggestion is simply looking at the needed values on the libGL.so installed on the system, then looking for &quot;libnvidia&quot; contained within.  If that is found then trigger a warning/error that this is known to conflict with QEMU.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12713</commentid>
    <comment_count>19</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-03-16 17:57:38 +0000</bug_when>
    <thetext>I attempted to run the poky-contrib gzhai/for_mark branch.  It unfortunately resulted in the same core dump as before.

As mentioned in my previous comment.  Likely a good alternative is to check the libraries actually being loaded.  One method would be:

ldd tmp/sysroots/x86_64-linux/usr/bin/qemu | grep nvidia

if the return code is &quot;0&quot;, then qemu was linked against an nvidia driver and may fail to load.  If it&apos;s != 0, then the nvidia libraries are not present and things are likely to work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12714</commentid>
    <comment_count>20</comment_count>
    <who name="Kevin Tian">kevin.tian</who>
    <bug_when>2011-03-16 18:09:36 +0000</bug_when>
    <thetext>yes, this way is more sane though we can expect all nvidia drivers falling into this pattern</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12715</commentid>
    <comment_count>21</comment_count>
    <who name="Kevin Tian">kevin.tian</who>
    <bug_when>2011-03-16 18:10:03 +0000</bug_when>
    <thetext>(In reply to comment #20)
&gt; yes, this way is more sane though we can expect all nvidia drivers falling into
&gt; this pattern

&apos;can&apos;-&gt;&apos;can&apos;t&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12752</commentid>
    <comment_count>22</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-17 01:56:41 +0000</bug_when>
    <thetext>Mark,
Can you test if following fix works on your fedora system? thanks,
http://git.pokylinux.org/cgit.cgi/poky-contrib/commit/?h=gzhai/fix2&amp;id=f596757000465a4b8350e16f21553a23b8bbedfa</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12791</commentid>
    <comment_count>23</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-17 20:33:44 +0000</bug_when>
    <thetext>After discussion with Mark, we agree we just give warnings to end user and document this as known issue, as different distribution need different solution.

New fix is @
http://git.pokylinux.org/cgit.cgi/poky-contrib/commit/?h=gzhai/fix3&amp;id=1c56783be10e6d51a801ccbee9e9ec5ae2c5db32</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12793</commentid>
    <comment_count>24</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2011-03-17 20:39:32 +0000</bug_when>
    <thetext>This patch looks good to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12797</commentid>
    <comment_count>25</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-17 20:49:55 +0000</bug_when>
    <thetext>Mark,
I have created a new bug requesting for the doc: bug 902.
Could you pls. provide fix for fedora?

Thanks,</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12944</commentid>
    <comment_count>26</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-23 19:03:04 +0000</bug_when>
    <thetext>Got fixed in master @ c0298557bad2e431f6dc87b6fda061cab561e14c</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>13067</commentid>
    <comment_count>27</comment_count>
    <who name="Edwin Zhai">edwin.zhai</who>
    <bug_when>2011-03-31 05:19:46 +0000</bug_when>
    <thetext>*** Bug 698 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>