ui/sdl2: fix segment fault caused by null pointer dereference
PATCH 1/1 ui/sdl2: fix segment fault caused by null pointer dereference
I found SDL_GetWindowFromID() sometimes return NULL when I start qemu via ssh forwarding even the window has been crated already. I am not sure whether this is a bug of SDL, but we'd better check it carefully.
--- ui/sdl2.c | 9 +++++++++ 1 file changed, 9 insertions(+)
ui/sdl2.c +9 -0
@@ -332,6 +332,9 @@ static void handle_keydown(SDL_Event *ev)int gui_key_modifier_pressed =get_mod_state ();int gui_keysym =0 ; +if (!scon) +return ; +if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) {switch (ev->key.keysym.scancode) {case SDL_SCANCODE_2 :
@@ -412,6 +415,9 @@ static void handle_keyup(SDL_Event *ev) {struct sdl2_console *scon =get_scon_from_window (ev->key.windowID); +if (!sconf) +return ; + scon->ignore_hotkeys = false;sdl2_process_key (scon, &ev->key); }
@@ -421,6 +427,9 @@ static void handle_textinput(SDL_Event *ev)struct sdl2_console *scon =get_scon_from_window (ev->text.windowID);QemuConsole *con = scon ? scon->dcl.con :NULL ; +if (!con) +return ; +if (qemu_console_is_graphic (con)) {return ; }
Signature · 1 line
2.20.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the asan build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1 === TEST SCRIPT END ===
BUILD pc-bios/optionrom/linuxboot_dma.img
BUILD pc-bios/optionrom/linuxboot_dma.raw
SIGN pc-bios/optionrom/linuxboot_dma.bin
/tmp/qemu-test/src/ui/sdl2.c:418:10: error: use of undeclared identifier 'sconf'
if (!sconf)
^1 error generated.
make: *** [/tmp/qemu-test/src/rules.mak:69: ui/sdl2.o] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
File "./tests/docker/docker.py", line 664, in <module>
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=4fa702e41a1541379c097297271712f7', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=x86_64-softmmu', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-xsh4udx7/src/docker-src.2020-04-27-08.25.03.16219:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-debug']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=4fa702e41a1541379c097297271712f7
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-xsh4udx7/src'
make: *** [docker-run-test-debug@fedora] Error 2
real 4m22.841s
user 0m9.190s
The full log is available at
http://patchew.org/logs/[email protected]/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH] ui/sdl2: fix segment fault caused by null pointer dereference
Message-id: [email protected]
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
cc4f090 ui/sdl2: fix segment fault caused by null pointer dereference
=== OUTPUT BEGIN ===
ERROR: braces {} are necessary for all arms of this statement #32: FILE: ui/sdl2.c:418:
+ if (!sconf)
[...]
ERROR: braces {} are necessary for all arms of this statement #42: FILE: ui/sdl2.c:430:
+ if (!con)
[...]
total: 2 errors, 0 warnings, 27 lines checked
Commit cc4f090c07bc (ui/sdl2: fix segment fault caused by null pointer dereference) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===
SIGN pc-bios/optionrom/pvh.bin
LINK qemu-io.exe/tmp/qemu-test/src/ui/sdl2.c: In function 'handle_keyup':/tmp/qemu-test/src/ui/sdl2.c:418:10: error: 'sconf' undeclared (first use in this function); did you mean 'scon'?
if (!sconf)
^~~~~
scon/tmp/qemu-test/src/ui/sdl2.c:418:10: note: each undeclared identifier is reported only once for each function it appears in
make: *** [/tmp/qemu-test/src/rules.mak:69: ui/sdl2.o] Error 1
make: *** Waiting for unfinished jobs....
LINK qemu-edid.exe
Traceback (most recent call last):
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=874a446966454b89aa835e525ea0e720', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-z9iu_bje/src/docker-src.2020-04-27-08.40.34.32723:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=874a446966454b89aa835e525ea0e720
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-z9iu_bje/src'
make: *** [docker-run-test-mingw@fedora] Error 2
real 2m58.815s
user 0m8.637s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 25 lines · Changbin Du
I found
SDL_GetWindowFromID()sometimes return NULL when I start qemu via ssh forwarding even the window has been crated already. I am not sure whether this is a bug of SDL, but we'd better check it carefully.Signed-off-by Changbin Du <[email protected]>--- ui/sdl2.c | 9 +++++++++ 1 file changed, 9 insertions(+)ui/sdl2.c +3
-0@@ -332,6 +332,9 @@ static void handle_keydown(SDL_Event *ev)int gui_key_modifier_pressed =get_mod_state ();int gui_keysym =0 ; +if (!scon) +return ; +if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) {switch (ev->key.keysym.scancode) {case SDL_SCANCODE_2 :
ui/sdl2.c static void handle_keyup(SDL_Event *ev) · line 419
Quoted 5 lines
ui/sdl2.c +2
-0@@ -412,6 +415,9 @@ static void handle_keyup(SDL_Event *ev) {struct sdl2_console *scon =get_scon_from_window (ev->key.windowID); +if (!sconf) +return ;
It's generally a good idea to make sure your patch at least compiles before sending it :-)
QEMU coding style demands {} on all if statements.
thanks
-- PMM
Quoted 29 lines · Peter Maydell
Quoted 28 lines · Changbin Du
I found
SDL_GetWindowFromID()sometimes return NULL when I start qemu via ssh forwarding even the window has been crated already. I am not sure whether this is a bug of SDL, but we'd better check it carefully.Signed-off-by Changbin Du <[email protected]>--- ui/sdl2.c | 9 +++++++++ 1 file changed, 9 insertions(+)ui/sdl2.c +3
-0@@ -332,6 +332,9 @@ static void handle_keydown(SDL_Event *ev)int gui_key_modifier_pressed =get_mod_state ();int gui_keysym =0 ; +if (!scon) +return ; +if (!scon->ignore_hotkeys && gui_key_modifier_pressed && !ev->key.repeat) {switch (ev->key.keysym.scancode) {case SDL_SCANCODE_2 :@@ -412,6 +415,9 @@ static void handle_keyup(SDL_Event *ev) {struct sdl2_console *scon =get_scon_from_window (ev->key.windowID);
Quoted 6 lines
ui/sdl2.c static void handle_keyup(SDL_Event *ev) · line 419
Quoted 2 lines
ui/sdl2.c +2
-0+if (!sconf) +return ;It's generally a good idea to make sure your patch at least compiles before sending it :-)
sorry for this. I don't know why my make didn't recompile it after changing.
Quoted 2 lines
QEMU coding style demands {} on all if statements.
sure.
Quoted 2 lines
thanks
-- PMM
Signature · 2 lines
Cheers, Changbin Du