[PATCH] kernelbase: Avoid NULL-pointer dereferences.

Gen Otsuji otsugen0000 at gmail.com
Sat May 16 09:56:34 CDT 2020

Thank you for your reply. My environment is FreeBSD amd64 12.1R
And I just tried to prepare test environment,
but many tests could not pass in my environment. many.
So, my environment is not trustworthy.

I tried only heap.ok.
cd dlls/kernel32/test
env LANG=C gmake heap.ok > log.txt 2>&1 (log.txt attached)
and debugger launched and backtrace.txt(attached)
but at the head of backtrace.txt
> couldn't load main module (2)
> Unhandled exception: stack overflow in 64-bit code (0x000000007b059535).
test wouldn't even launch.
I give up now to go further.

So far, as this is an assumption, maybe compiler,
by CFLAGS or something related with Optimization,
erased the code "*p|=0" in memory.s
( you can get assembler code by compiling with CFLAGS+=--save-temps )
Even though the p is declared volatile, because this code does
nothing,it's erased.(my assumption)
but this should not happen.
I think CFLAGS with -O0 will do(?)

-------------- next part --------------
../../../../wine/tools/runtest -v -v -v -P wine -T ../../.. -M kernel32.dll -p kernel32_test.exe.so heap && touch heap.ok
0024:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
002c:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
002c:fixme:ntdll:get_firmware_info info_class SYSTEM_FIRMWARE_TABLE_INFORMATION
002c:fixme:ntdll:get_firmware_info info_class SYSTEM_FIRMWARE_TABLE_INFORMATION
0034:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
003c:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
0048:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
0050:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
0070:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
0078:err:ntoskrnl:ZwLoadDriver failed to create driver L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\wineusb": c0000142
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"wineusb" failed to start: 1114
0094:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
wine: Unhandled stack overflow at address 000000007B059535 (thread 0024), starting debugger...
00b4:err:nls:init_unix_codepage unrecognized charset 'US-ASCII'
gmake: *** [Makefile:747: heap.ok] Error 253
-------------- next part --------------
couldn't load main module (2)
Unhandled exception: stack overflow in 64-bit code (0x000000007b059535).
Register dump:
 rip:000000007b059535 rsp:000000000021f660 rbp:000000000021f7f0 eflags:00010202 (  R- --  I   - - - )
 rax:ffffffffdeadbeef rbx:00000000001102e2 rcx:000000000021f6c0 rdx:000000000021f6a0
 rsi:000000007ffd8000 rdi:0000000000722f40  r8:0000000000000001  r9:0000000000000006 r10:0000000000000000
 r11:00000000001002d8 r12:000000007ffd8000 r13:0000000000000001 r14:000000007ffd8000 r15:0000000000000100
Stack dump:
0x000000000021f660:  000000000021f7f0 000000007b059a27
0x000000000021f670:  0000000000000118 0000000000000000
0x000000000021f680:  0000000000000000 0000000000000000
0x000000000021f690:  0000000000000000 ffffffffdeadbeef
0x000000000021f6a0:  000000000021fb80 000000007b099b90
0x000000000021f6b0:  000000000021fb80 000000007b099b90
0x000000000021f6c0:  000000000021f6a0 00000000001102e2
0x000000000021f6d0:  000000000021f660 000000000021f7f0
0x000000000021f6e0:  000000007ffd8000 0000000000722f40
0x000000000021f6f0:  00000000001102e2 0000000000000001
0x000000000021f700:  000000007ffd8000 0000000000000100
0x000000000021f710:  000000007b059464 0000000000000100
=>0 0x000000007b059535 (0x000000000021f7f0)
0x000000007b059535: addb	%al,(%rax)
Module	Address					Debug info	Name (13 modules)
PE	        68500000-        685da000	Deferred        user32
PE	        68780000-        68784000	Deferred        setupapi
PE	        687f0000-        687f4000	Deferred        version
PE	        68830000-        68834000	Deferred        ucrtbase
PE	        68950000-        68954000	Deferred        advapi32
PE	        689c0000-        689c3000	Deferred        sechost
PE	        68a00000-        68a04000	Deferred        rpcrt4
PE	        68aa0000-        68aa4000	Deferred        gdi32
PE	        68c50000-        68c54000	Deferred        msvcrt
PE	        69190000-        69194000	Deferred        imm32
PE	        7b010000-        7b017000	Deferred        kernelbase
PE	        7b410000-        7b469000	Deferred        kernel32
PE	        7bc20000-        7bc24000	Deferred        ntdll
process  tid      prio (all id:s are in hex)
00000020 (D) Z:\home\user\work\test\dlls\kernel32\tests\kernel32_test.exe
	000000b8    0
	00000024    0 <==
00000038 services.exe
	000000a0    0
	00000074    0
	0000005c    0
	00000058    0
	00000054    0
	00000040    0
	0000003c    0
00000044 plugplay.exe
	0000008c    0
	00000088    0
	00000084    0
	00000068    0
	00000064    0
	00000060    0
	00000048    0
0000004c explorer.exe
	000000a8    0
	0000009c    0
	00000098    0
	00000050    0
0000006c winedevice.exe
	00000080    0
	0000007c    0
	00000078    0
	00000070    0
00000090 winedevice.exe
	000000ac    0
	000000a4    0
	00000094    0
System information:
    Wine build: wine-5.8-174-ge0bda3aa3b
    Platform: x86_64
    Version: Windows 7
    Host system: FreeBSD
    Host version: 12.1-RELEASE-p5

More information about the wine-devel mailing list