http://bugs.winehq.org/show_bug.cgi?id=34176
Bug #: 34176 Summary: Kernel32:CompareStringW strange behavior ? Product: Wine Version: 1.6 Platform: x86-64 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 AssignedTo: wine-bugs@winehq.org ReportedBy: wine.manette@manette.be Classification: Unclassified
Created attachment 45460 --> http://bugs.winehq.org/attachment.cgi?id=45460 Sorce and compiled executable for wineTest.exe + winedbg log.txt
Hi all, I'm running wine 1.6 (i386) under Debian 7.1 (x86_64). When running a console program of mine (Delphi XE2 compiled under Windows Vista) I'm observing an important behavior difference under wine than nativevely.
I narrowed down the symptom to a string comparison of some sort. Source file below is a code snippet to reproduce the problem (source is UTF-8, Delphi is utf-8 / WideString, WideChar aware).
Here is the (correct/expected) result when program is run natively under Windows Vista:
G:__Project-2\Code\wineTest>wineTest * TEST-001: TRUE * TEST-002: TRUE * TEST-003: TRUE * TEST-004: TRUE TRUE * TEST-005: TRUE TRUE * TEST-003: TRUE TRUE
Here is the same program output when run from Wine:
root@Bilbo-100:~# wine wineTest.exe Wine cannot find the ncurses library (libncurses.so.5). fixme:thread:GetThreadUILanguage : stub, returning default language. fixme:thread:GetThreadPreferredUILanguages 56, 0x33d8f8, (nil) 0x33d920 fixme:thread:GetThreadPreferredUILanguages 56, 0x33d8f8, (nil) 0x33d920 * TEST-001: TRUE * TEST-002: TRUE * TEST-003: TRUE * TEST-004: TRUE FALSE * TEST-005: TRUE FALSE * TEST-003: TRUE FALSE
For what I understood the TStringList IndexOf method may use Windows API's CompareStringW function (http://source.winehq.org/WineAPI/CompareStringW.html)
Is this a configuration problem (locale ?) May this be a bug or implementation problem ?
I can provide the corrsponding binary wineTest.exe
//////////////////////////////////////////////////
Using winedbg I could crosscheck that CompareStringW for two different strings result in equality (CSTR_LESS_THAN = 1, CSTR_EQUAL = 2, CSTR_GREATER_THAN = 3). Maybe this is because of locale setting or flags setup ?
root@Bilbo-100:~# WINEDEBUG=+relay,+snoop wine wineTest.exe &> log.txt
root@Bilbo-100:~# grep CompareStringW log.txt 0009:Call KERNEL32.CompareStringW(00000400,00000001,00549cac L"m\00b2",00000002,00449890 L"m\00b2",00000002) ret=004187d0 0009:Ret KERNEL32.CompareStringW() retval=00000002 ret=004187d0 0009:Call KERNEL32.CompareStringW(00000400,00000001,00549cac L"m\00b2",00000002,004498bc L"m2",00000002) ret=004187d0 0009:Ret KERNEL32.CompareStringW() retval=00000002 ret=004187d0 0009:Call KERNEL32.CompareStringW(00000400,00000001,00549cac L"m\00b3",00000002,004498f8 L"m\00b3",00000002) ret=004187d0 0009:Ret KERNEL32.CompareStringW() retval=00000002 ret=004187d0 0009:Call KERNEL32.CompareStringW(00000400,00000001,00549cac L"m\00b3",00000002,0044990c L"m3",00000002) ret=004187d0 0009:Ret KERNEL32.CompareStringW() retval=00000002 ret=004187d0 0009:Call KERNEL32.CompareStringW(00000400,00000001,00549cac L"\00e9\00e9\00e9",00000003,00449920 L"\00e9\00e9\00e9",00000003) ret=004187d0 0009:Ret KERNEL32.CompareStringW() retval=00000002 ret=004187d0 0009:Call KERNEL32.CompareStringW(00000400,00000001,00549cac L"\00e9\00e9\00e9",00000003,00449934 L"eee",00000003) ret=004187d0 0009:Ret KERNEL32.CompareStringW() retval=00000002 ret=004187d0
///////////////////////////////////////////////////
program wineTest;
{$APPTYPE CONSOLE}
Uses Classes;
var
sl : TStringList;
begin
Write(ErrOutput, '* TEST-001: '); if not('m²'='m2') then Writeln(ErrOutput, 'TRUE') else Writeln(ErrOutput, 'FALSE');
Write(ErrOutput, '* TEST-002: '); if not('m³'='m3') then Writeln(ErrOutput, 'TRUE') else Writeln(ErrOutput, 'FALSE');
Write(ErrOutput, '* TEST-003: '); if not('ééé'='eee') then Writeln(ErrOutput, 'TRUE') else Writeln(ErrOutput, 'FALSE');
sl := TStringList.Create;
Write(ErrOutput, '* TEST-004: '); sl.Clear; sl.Add('m²'); if not(sl.IndexOf('m²')<0) then Write(ErrOutput, 'TRUE') else Write(ErrOutput, 'FALSE'); Write(ErrOutput, ' '); if sl.IndexOf('m2')<0 then Writeln(ErrOutput, 'TRUE') else Writeln(ErrOutput, 'FALSE');
Write(ErrOutput, '* TEST-005: '); sl.Clear; sl.Add('m³'); if not(sl.IndexOf('m³')<0) then Write(ErrOutput, 'TRUE') else Write(ErrOutput, 'FALSE'); Write(ErrOutput, ' '); if sl.IndexOf('m3')<0 then Writeln(ErrOutput, 'TRUE') else Writeln(ErrOutput, 'FALSE');
Write(ErrOutput, '* TEST-003: '); sl.Clear; sl.Add('ééé'); if not(sl.IndexOf('ééé')<0) then Write(ErrOutput, 'TRUE') else Write(ErrOutput, 'FALSE'); Write(ErrOutput, ' '); if sl.IndexOf('eee')<0 then Writeln(ErrOutput, 'TRUE') else Writeln(ErrOutput, 'FALSE');
end.
http://bugs.winehq.org/show_bug.cgi?id=34176
Emmanuel Jacobs wine.manette@manette.be changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |wine.manette@manette.be
http://bugs.winehq.org/show_bug.cgi?id=34176
--- Comment #1 from Emmanuel Jacobs wine.manette@manette.be 2013-07-31 12:29:23 CDT --- Using this: http://conus.info/gt/gt.html
I could do almost the same debug in Vista.
You see that first two call parameters are the same, results are 2,3,2,3,2,3 instead of Wine's "incorrect" 2,2,2,2,2,2
PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW (0x400, 1, 0x17b279c, 2, 0x449890, 2) (called from 0x4187d0 (wineTest.exe!BASE+0x187d0)) PID=5240|Call stack of thread TID=6304 Current 0x449890 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW -> 2 PID=5240|Call stack of thread TID=6304 Current 0x449890 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW (0x400, 1, 0x17b279c, 2, 0x4498bc, 2) (called from 0x4187d0 (wineTest.exe!BASE+0x187d0)) PID=5240|Call stack of thread TID=6304 Current 0x4498bc (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW -> 3 PID=5240|Call stack of thread TID=6304 Current 0x4498bc (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW (0x400, 1, 0x17b279c, 2, 0x4498f8, 2) (called from 0x4187d0 (wineTest.exe!BASE+0x187d0)) PID=5240|Call stack of thread TID=6304 Current 0x4498f8 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW -> 2 PID=5240|Call stack of thread TID=6304 Current 0x4498f8 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW (0x400, 1, 0x17b279c, 2, 0x44990c, 2) (called from 0x4187d0 (wineTest.exe!BASE+0x187d0)) PID=5240|Call stack of thread TID=6304 Current 0x44990c (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW -> 3 PID=5240|Call stack of thread TID=6304 Current 0x44990c (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW (0x400, 1, 0x17b279c, 3, 0x449920, 3) (called from 0x4187d0 (wineTest.exe!BASE+0x187d0)) PID=5240|Call stack of thread TID=6304 Current 0x449920 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW -> 2 PID=5240|Call stack of thread TID=6304 Current 0x449920 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW (0x400, 1, 0x17b279c, 3, 0x449934, 3) (called from 0x4187d0 (wineTest.exe!BASE+0x187d0)) PID=5240|Call stack of thread TID=6304 Current 0x449934 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW -> 3 PID=5240|Call stack of thread TID=6304 Current 0x449934 (EBP) is not within current stack limits (top=0x130000, bottom=0x12c000) PID=5240|TID=6304|(0) KERNEL32.dll!CompareStringW (0x400, 1, 0x77462b14, 0xffffffff, 0x771b744c, 0xffffffff) (called from 0x771071d9 (KERNEL32.dll!lstrcmpiW+0x1f)) PID=5240|Call stack of thread TID=6304
http://bugs.winehq.org/show_bug.cgi?id=34176
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
http://bugs.winehq.org/show_bug.cgi?id=34176
--- Comment #2 from Emmanuel Jacobs wine.manette@manette.be 2013-07-31 13:09:45 CDT --- Built following instructions here: http://verahill.blogspot.be/2013/07/4xx-compiling-wine-16-on-debian-using.ht...
Please do find the .deb package I compiled here: http://manette.be/files/wine_1.6-1_i386.deb (won't be there forever, if I remove it ask again if required).
Installed on the 7.1 Debian x86_64 using:
dpkg --add-architecture i386 apt-get update apt-get install ia32-libs
chown $USER wine_1.6-1_i386.deb dpkg -i wine_1.6-1_i386.deb
wine --version // wine-1.6
http://bugs.winehq.org/show_bug.cgi?id=34176
--- Comment #3 from Emmanuel Jacobs wine.manette@manette.be 2013-07-31 15:45:48 CDT --- Same problem with actual Debian package for Wheezy 7.1 (i386 multiarch):
Installed with:
dpkg --add-architecture i386 apt-get update apt-get install wine-bin:i386
root@Gollum-103:~# uname -a Linux Gollum-103 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 GNU/Linux root@Gollum-103:~# uname -r 3.2.0-4-amd64 root@Gollum-103:~# uname -m x86_64 root@Gollum-103:~# cat /etc/debian_version 7.1 root@Gollum-103:~# wine --version wine-1.4.1 root@Gollum-103:~# wine wineTest.exe Application tried to create a window, but no driver could be loaded. Make sure that your X server is running and that $DISPLAY is set correctly. err:systray:initialize_systray Could not create tray window * TEST-001: TRUE * TEST-002: TRUE * TEST-003: TRUE * TEST-004: TRUE FALSE * TEST-005: TRUE FALSE * TEST-003: TRUE FALSE fixme:process:GetLogicalProcessorInformation ((nil),0x33fdd8): stub
http://bugs.winehq.org/show_bug.cgi?id=34176
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dank@kegel.com
--- Comment #4 from Dan Kegel dank@kegel.com 2013-07-31 23:16:25 CDT --- Is this related to bug 9583 and/or bug 10767?
http://bugs.winehq.org/show_bug.cgi?id=34176
--- Comment #5 from Emmanuel Jacobs wine.manette@manette.be 2013-08-02 11:18:59 CDT --- (In reply to comment #4)
Is this related to bug 9583 and/or bug 10767?
Sure for bug 9583 (altough behavior described there impact the same function it is not the same effect, I'm complaining about equality of that function, they are complaining about < or > aka sorting).
I see in wine source code (http://source.winehq.org/source/dlls/kernel32/locale.c#L2913) tahat CompareStringW is calling CompareStringEx (http://source.winehq.org/source/dlls/kernel32/locale.c#L2922) wihich in turn is calling wine_compare_string (http://source.winehq.org/source/libs/wine/sortkey.c#L333).
Locale is not "forwarded" from ...W to ...Ex so IMHO this should not be a locale configuration problem (but maybe locale is checked in that very last function ?)
Given the second parameters (0x1) passed from the program (both when executed from Windows as well as from Wine) to the CompareStringW call is NORM_IGNORECASE(http://source.winehq.org/source/include/winnls.h#L345) the question is should é be = to e, ² be = to 2 and 3 be = to ³ from the unicode standard point of view ? COuld we tell Wine to behave like Windows for this matter ?
Maybe we can have the point of view of Dmitry Timoshkov which seems to have introduced the code into Wine ?
http://bugs.winehq.org/show_bug.cgi?id=34176
Emmanuel Jacobs wine.manette@manette.be changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dtimoshkov@codeweavers.com
http://bugs.winehq.org/show_bug.cgi?id=34176
--- Comment #6 from Emmanuel Jacobs wine.manette@manette.be 2013-08-02 11:24:41 CDT --- Dmitry (hope the email adress I found is the right one, hop I do not bother you with this...)
http://bugs.winehq.org/show_bug.cgi?id=34176
Dmitry Timoshkov dmitry@baikal.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC|dtimoshkov@codeweavers.com |
--- Comment #7 from Dmitry Timoshkov dmitry@baikal.ru 2013-08-05 23:17:35 CDT --- (In reply to comment #5)
Given the second parameters (0x1) passed from the program (both when executed from Windows as well as from Wine) to the CompareStringW call is NORM_IGNORECASE(http://source.winehq.org/source/include/winnls.h#L345) the question is should é be = to e, ² be = to 2 and 3 be = to ³ from the unicode standard point of view ? COuld we tell Wine to behave like Windows for this matter ?
I doubt that NORM_IGNORECASE works like that.
(In reply to comment #6)
Dmitry (hope the email adress I found is the right one, hop I do not bother you with this...)
That address is no longer valid.
https://bugs.winehq.org/show_bug.cgi?id=34176
zaplo00@mailfence.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |zaplo00@mailfence.com
--- Comment #8 from zaplo00@mailfence.com --- wine-3.10 still has broken behaviour with wineTest.exe:
0009:fixme:thread:GetThreadUILanguage : stub, returning default language. 0009:fixme:nls:GetThreadPreferredUILanguages 00000038, 0x33d958, (nil) 0x33d980 0009:fixme:nls:get_dummy_preferred_ui_language (0x38 0x33d958 (nil) 0x33d980) returning a dummy value (current locale) 0009:fixme:nls:GetThreadPreferredUILanguages 00000038, 0x33d958, 0x58a680 0x33d980 0009:fixme:nls:get_dummy_preferred_ui_language (0x38 0x33d958 0x58a680 0x33d980) returning a dummy value (current locale) * TEST-001: TRUE * TEST-002: TRUE * TEST-003: TRUE * TEST-004: TRUE FALSE * TEST-005: TRUE FALSE * TEST-003: TRUE FALSE
https://bugs.winehq.org/show_bug.cgi?id=34176
Sagawa sagawa.aki+winebugs@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sagawa.aki+winebugs@gmail.c | |om
--- Comment #9 from Sagawa sagawa.aki+winebugs@gmail.com --- Commit d8c973ad95ba5e8a9a51df0dd9be587950179ec3 should fix this issue. Admin, could you mark fixed?
% wine wineTest.exe 0024:fixme:thread:GetThreadUILanguage : stub, returning default language. 0024:fixme:nls:RtlGetThreadPreferredUILanguages 00000038, 0055D9C8, 00000000 0055D9F0 0024:fixme:nls:get_dummy_preferred_ui_language (0x38 0055D9C8 00000000 0055D9F0) returning a dummy value (current locale) 0024:fixme:nls:RtlGetThreadPreferredUILanguages 00000038, 0055D9C8, 0147A680 0055D9F0 0024:fixme:nls:get_dummy_preferred_ui_language (0x38 0055D9C8 0147A680 0055D9F0) returning a dummy value (current locale) * TEST-001: TRUE * TEST-002: TRUE * TEST-003: TRUE * TEST-004: TRUE TRUE * TEST-005: TRUE TRUE * TEST-003: TRUE TRUE
https://bugs.winehq.org/show_bug.cgi?id=34176
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Fixed by SHA1| |d8c973ad95ba5e8a9a51df0dd9b | |e587950179ec3 Resolution|--- |FIXED
--- Comment #10 from Nikolay Sivov bunglehead@gmail.com --- Marking fixed.
https://bugs.winehq.org/show_bug.cgi?id=34176
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #11 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 7.11.