https://bugs.winehq.org/show_bug.cgi?id=36153
Bug ID: 36153 Summary: Borderlands 2 mouse focus no longer works properly Product: Wine Version: 1.7.17 Hardware: x86 OS: Linux Status: NEW Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs@winehq.org Reporter: erich.e.hoover@gmail.com Regression SHA1: 4d40aea0bde11e8c856c1c7047a429836b95998e
Using the mouse for the menus in Borderlands 2 no longer sets the appropriate focus. Items in the background frequently maintain the focus instead of the menu that opened. Regression testing points to: 4d40aea0bde11e8c856c1c7047a429836b95998e is the first bad commit commit 4d40aea0bde11e8c856c1c7047a429836b95998e Author: Piotr Caban piotr@codeweavers.com Date: Thu Apr 17 13:07:00 2014 +0200
msvcr100: Share the source code with msvcrt.
:040000 040000 d736562de0aa311ff4841b671ed018a859d74a84 46cbf9e06828dc989b3e09eeb310dfb654d79de2 M dlls :040000 040000 c4ce5030770a19ed507850f7664c0f178a7bf870 21c8e818efa0aa5ee052037d70c82372f1165463 M tools
https://bugs.winehq.org/show_bug.cgi?id=36153
Erich Hoover erich.e.hoover@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |piotr@codeweavers.com
--- Comment #1 from Erich Hoover erich.e.hoover@gmail.com --- Whoops, forgot to add Piotr to the CC list. Note: As I have time I'll try to do a linear search for the responsible function, I assume that version-specific behavior is responsible for the problem.
http://bugs.winehq.org/show_bug.cgi?id=36153
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |piotr.caban@gmail.com
--- Comment #2 from Piotr Caban piotr.caban@gmail.com --- Without the patch wine was using native msvcr100 by default. Probably it never worked with builtin msvcr100.dll.
https://bugs.winehq.org/show_bug.cgi?id=36153
Jerome Leclanche adys.wh@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |adys.wh@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #3 from Piotr Caban piotr.caban@gmail.com --- Please attach a log with msvcrt,tid,seh,relay debug channels.
https://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #4 from Jerome Leclanche adys.wh@gmail.com --- I can't get you a relay log. It grows to 3 gigabytes within seconds and no matter how much stuff I add in RelayExclude it's still unusable. RelayFromExclude doesn't seem to do anything either...
Without +relay it's crashing. Looking into it, might be one of my patches.
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #5 from Erich Hoover erich.e.hoover@gmail.com --- I'm sorry I haven't had a chance to get to this yet, been a little busy with work. Is it possible to easily forward individual calls to the native DLL with the spec file? That might help narrow things down.
https://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #6 from Jerome Leclanche adys.wh@gmail.com --- Created attachment 48333 --> https://bugs.winehq.org/attachment.cgi?id=48333 Screenshot of behaviour
This is a screenshot showcasing the issue with the video screen.
https://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #7 from Jerome Leclanche adys.wh@gmail.com --- Created attachment 48334 --> https://bugs.winehq.org/attachment.cgi?id=48334 WINEDEBUG=msvcrt,tid,seh WINEPREFIX=~/.local/share/wineprefixes/steam ~/src/wine/build32/wine Borderlands2.exe -NoLauncher &> out.txt
Debug output attached. No +relay for the reasons highlighted above, sorry
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #8 from Piotr Caban piotr.caban@gmail.com --- Could you please attach output of `winedump -j import BorderLands2.exe` as well?
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #9 from Erich Hoover erich.e.hoover@gmail.com --- Created attachment 48335 --> http://bugs.winehq.org/attachment.cgi?id=48335 BL2 executable linking dump
(In reply to Piotr Caban from comment #8)
Could you please attach output of `winedump -j import BorderLands2.exe` as well?
Ah-ha, that I can do from work!
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #10 from Piotr Caban piotr.caban@gmail.com --- The game is using qsort in broken way. It uses comparator that always returns 1 and expects that data is reordered in some specific way. In order to fix it wine's qsort implementation needs to call comparator in the same way as native does.
The way comparator is called is not preserved between different versions of msvcrXX.dll (I've checked only msvcrt.dll and msvcr100.dll).
It looks like msvcrt uses very similar sorting algorithm as glibc. It uses qsort (pivot element is selected from 3 elements) and falls back to insertion sort on small portions of table (with less than 9 elements).
Adding something like this in qsort_s fixes Borderlands 2 for me: /* Borderlands 2 depends on comparator calling order for small tables */ if (nmemb <= 8) { MSVCRT_size_t e, i; char *max, *p, tmp;
for(e=nmemb; e>1; e--) { max = base; for(i=1; i<e; i++) { p = (char*)base + i*size; if(compar(context, p, max) > 0) max = p; }
if(p != max) { for(i=size; i; i--) { tmp = *max; *max++ = *p; *p++ = tmp; } } }
return; }
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #11 from Erich Hoover erich.e.hoover@gmail.com --- (In reply to Piotr Caban from comment #10)
... The way comparator is called is not preserved between different versions of msvcrXX.dll (I've checked only msvcrt.dll and msvcr100.dll). ... Adding something like this in qsort_s fixes Borderlands 2 for me: ...
Fixes the problem for me as well. Is this something where AJ would allow a "#define MSVCR100"/"#ifdef MSVCR100" so that msvcr100 has this behavior without breaking other versions?
http://bugs.winehq.org/show_bug.cgi?id=36153
Luke Bratch l_bratch@yahoo.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |l_bratch@yahoo.co.uk
http://bugs.winehq.org/show_bug.cgi?id=36153
mikachu@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mikachu@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #12 from Piotr Caban piotr.caban@gmail.com --- (In reply to Erich Hoover from comment #11)
Fixes the problem for me as well. Is this something where AJ would allow a "#define MSVCR100"/"#ifdef MSVCR100" so that msvcr100 has this behavior without breaking other versions?
I think that better solution is to rewrite qsort so it doesn't allocate additional memory. While doing it one can implement fallback to simpler sort for small partitions. This way the function will be much more similar to native implementation.
http://bugs.winehq.org/show_bug.cgi?id=36153
--- Comment #13 from Piotr Caban piotr.caban@gmail.com --- It should be working now. Please retest.
http://bugs.winehq.org/show_bug.cgi?id=36153
Erich Hoover erich.e.hoover@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |b703afda86ef962c617ff33f7b8 | |a552ea550d1e5 Status|NEW |RESOLVED Resolution|--- |FIXED
--- Comment #14 from Erich Hoover erich.e.hoover@gmail.com --- Yup, that did the trick - thanks so much!
https://bugs.winehq.org/show_bug.cgi?id=36153
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #15 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 1.7.20.