* [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl
@ 2016-05-31 20:56 Cole Robinson
2016-05-31 21:49 ` Peter Maydell
2016-06-01 6:38 ` Gerd Hoffmann
0 siblings, 2 replies; 5+ messages in thread
From: Cole Robinson @ 2016-05-31 20:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Cole Robinson
$ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -sdl
Segmentation fault (core dumped)
0 0x00005555559631af in sdl_display_init (ds=<optimized out>, full_screen=0, no_frame=<optimized out>) at ui/sdl2.c:822
1 0x00005555556c8a9a in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4527
Setting the window icon assumes there's always an SDL output window
available, which isn't the case with when there's no video device,
like via -nodefaults. So don't try to set a window icon when we don't
have any outputs.
https://bugzilla.redhat.com/show_bug.cgi?id=1340931
---
ui/sdl2.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 909038f..d0e0a41 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -812,16 +812,18 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
register_displaychangelistener(&sdl2_console[i].dcl);
}
- /* Load a 32x32x4 image. White pixels are transparent. */
- filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
- if (filename) {
- SDL_Surface *image = SDL_LoadBMP(filename);
- if (image) {
- uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
- SDL_SetColorKey(image, SDL_TRUE, colorkey);
- SDL_SetWindowIcon(sdl2_console[0].real_window, image);
+ if (sdl2_num_outputs) {
+ /* Load a 32x32x4 image. White pixels are transparent. */
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
+ if (filename) {
+ SDL_Surface *image = SDL_LoadBMP(filename);
+ if (image) {
+ uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
+ SDL_SetColorKey(image, SDL_TRUE, colorkey);
+ SDL_SetWindowIcon(sdl2_console[0].real_window, image);
+ }
+ g_free(filename);
}
- g_free(filename);
}
if (full_screen) {
--
2.5.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl
2016-05-31 20:56 [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl Cole Robinson
@ 2016-05-31 21:49 ` Peter Maydell
2016-06-01 6:39 ` Gerd Hoffmann
2016-06-01 6:38 ` Gerd Hoffmann
1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2016-05-31 21:49 UTC (permalink / raw)
To: Cole Robinson; +Cc: QEMU Developers, Gerd Hoffmann
On 31 May 2016 at 21:56, Cole Robinson <crobinso@redhat.com> wrote:
> $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -sdl
> Segmentation fault (core dumped)
>
> 0 0x00005555559631af in sdl_display_init (ds=<optimized out>, full_screen=0, no_frame=<optimized out>) at ui/sdl2.c:822
> 1 0x00005555556c8a9a in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4527
>
> Setting the window icon assumes there's always an SDL output window
> available, which isn't the case with when there's no video device,
> like via -nodefaults. So don't try to set a window icon when we don't
> have any outputs.
Presumably we also crash for boards like the arm 'virt'
which just don't have a display device at all...
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl
2016-05-31 20:56 [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl Cole Robinson
2016-05-31 21:49 ` Peter Maydell
@ 2016-06-01 6:38 ` Gerd Hoffmann
2016-06-01 11:31 ` Cole Robinson
1 sibling, 1 reply; 5+ messages in thread
From: Gerd Hoffmann @ 2016-06-01 6:38 UTC (permalink / raw)
To: Cole Robinson; +Cc: qemu-devel
On Di, 2016-05-31 at 16:56 -0400, Cole Robinson wrote:
> $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -sdl
> Segmentation fault (core dumped)
>
> 0 0x00005555559631af in sdl_display_init (ds=<optimized out>, full_screen=0, no_frame=<optimized out>) at ui/sdl2.c:822
> 1 0x00005555556c8a9a in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4527
>
> Setting the window icon assumes there's always an SDL output window
> available, which isn't the case with when there's no video device,
> like via -nodefaults. So don't try to set a window icon when we don't
> have any outputs.
Hmm, I guess we can skip pretty much all of the init in case there are
no outputs:
@@ -794,6 +794,9 @@ void sdl_display_init(DisplayState *ds, int
full_screen, int no_frame)
}
}
sdl2_num_outputs = i;
+ if (sdl2_num_outputs == 0) {
+ return;
+ }
sdl2_console = g_new0(struct sdl2_console, sdl2_num_outputs);
for (i = 0; i < sdl2_num_outputs; i++) {
QemuConsole *con = qemu_console_lookup_by_index(i);
Maybe even move up the loop counting the outputs, so we can skip the
SDL_Init() call too. We don't get a empty window then.
cheers,
Gerd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl
2016-05-31 21:49 ` Peter Maydell
@ 2016-06-01 6:39 ` Gerd Hoffmann
0 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-06-01 6:39 UTC (permalink / raw)
To: Peter Maydell; +Cc: Cole Robinson, QEMU Developers
On Di, 2016-05-31 at 22:49 +0100, Peter Maydell wrote:
> On 31 May 2016 at 21:56, Cole Robinson <crobinso@redhat.com> wrote:
> > $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -sdl
> > Segmentation fault (core dumped)
> >
> > 0 0x00005555559631af in sdl_display_init (ds=<optimized out>, full_screen=0, no_frame=<optimized out>) at ui/sdl2.c:822
> > 1 0x00005555556c8a9a in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4527
> >
> > Setting the window icon assumes there's always an SDL output window
> > available, which isn't the case with when there's no video device,
> > like via -nodefaults. So don't try to set a window icon when we don't
> > have any outputs.
>
> Presumably we also crash for boards like the arm 'virt'
> which just don't have a display device at all...
There are still the vc's for monitor and serial.
cheers,
Gerd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl
2016-06-01 6:38 ` Gerd Hoffmann
@ 2016-06-01 11:31 ` Cole Robinson
0 siblings, 0 replies; 5+ messages in thread
From: Cole Robinson @ 2016-06-01 11:31 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
On 06/01/2016 02:38 AM, Gerd Hoffmann wrote:
> On Di, 2016-05-31 at 16:56 -0400, Cole Robinson wrote:
>> $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -sdl
>> Segmentation fault (core dumped)
>>
>> 0 0x00005555559631af in sdl_display_init (ds=<optimized out>, full_screen=0, no_frame=<optimized out>) at ui/sdl2.c:822
>> 1 0x00005555556c8a9a in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4527
>>
>> Setting the window icon assumes there's always an SDL output window
>> available, which isn't the case with when there's no video device,
>> like via -nodefaults. So don't try to set a window icon when we don't
>> have any outputs.
>
> Hmm, I guess we can skip pretty much all of the init in case there are
> no outputs:
>
> @@ -794,6 +794,9 @@ void sdl_display_init(DisplayState *ds, int
> full_screen, int no_frame)
> }
> }
> sdl2_num_outputs = i;
> + if (sdl2_num_outputs == 0) {
> + return;
> + }
> sdl2_console = g_new0(struct sdl2_console, sdl2_num_outputs);
> for (i = 0; i < sdl2_num_outputs; i++) {
> QemuConsole *con = qemu_console_lookup_by_index(i);
>
>
> Maybe even move up the loop counting the outputs, so we can skip the
> SDL_Init() call too. We don't get a empty window then.
>
Works for me, I figured there was a better approach to handle -sdl + no
display device. If you send a patch I'll test it
Thanks,
Cole
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-06-01 11:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 20:56 [Qemu-devel] [PATCH] ui: sdl2: Fix crash with -nodefaults -sdl Cole Robinson
2016-05-31 21:49 ` Peter Maydell
2016-06-01 6:39 ` Gerd Hoffmann
2016-06-01 6:38 ` Gerd Hoffmann
2016-06-01 11:31 ` Cole Robinson
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.