http://bugs.winehq.org/show_bug.cgi?id=31507
Bug #: 31507 Summary: midiInOpen x64 crash due to callback address 32-bit truncation Product: Wine Version: unspecified Platform: x86-64 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winmm&mci AssignedTo: wine-bugs@winehq.org ReportedBy: georgewi@oss3d.com Classification: Unclassified
midiInOpen seems to crash at calling the address, which looks like the lower 32-bit of the callback function address passed to it as a parameter.
I believe, the callback address is somewhere truncated from 64-bit to 32-bit in the internal logic.
The affected software is this (64-bit standalone executable): http://www.truepianos.com/downloads.php
I couldn't find the exact reason for this problem within wine sources.
http://bugs.winehq.org/show_bug.cgi?id=31507
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com 2012-08-19 09:25:27 CDT --- What is your wine version? Please attach a backtrace here as a text file.
http://bugs.winehq.org/show_bug.cgi?id=31507
--- Comment #2 from George Yohng georgewi@oss3d.com 2012-08-19 14:41:33 CDT --- Created attachment 41425 --> http://bugs.winehq.org/attachment.cgi?id=41425 Crash backtrace
http://bugs.winehq.org/show_bug.cgi?id=31507
--- Comment #3 from George Yohng georgewi@oss3d.com 2012-08-19 14:43:07 CDT --- Versions - the ones coming with the last OpenSuSE and ArchLinux:
OpenSuSe: wine-1.4 ArchLinux: wine-1.5.11
Both of them have the problem with x64.
The backtrace is attached in the previous comment.
Please note, the crash address is: 0x000000004004b2f0
While the actual location of the MIDI callback is: 0x000000014004b2f0
So I assume it gets truncated somewhere in the way.
http://bugs.winehq.org/show_bug.cgi?id=31507
--- Comment #4 from George Yohng georgewi@oss3d.com 2012-08-19 14:50:46 CDT --- Created attachment 41426 --> http://bugs.winehq.org/attachment.cgi?id=41426 Illustration of the problem with the part of the source code
Another attachment added. Here is a screenshot of the error log. I added a printf into the source code to verify the problem.
Needless to say, the same executable works on Windows without problems, it also works flawlessly when its counterpart is compiled for x86-32 and run under Wine.
http://bugs.winehq.org/show_bug.cgi?id=31507
George Yohng georgewi@oss3d.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.5.11
http://bugs.winehq.org/show_bug.cgi?id=31507
--- Comment #5 from Nikolay Sivov bunglehead@gmail.com 2012-08-19 20:10:17 CDT --- Hi, George.
I think I found a problem you're seeing, pointer truncation happens in wine sound driver at MIDI_NotifyClient():
--- static void MIDI_NotifyClient(UINT wDevID, WORD wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) { DWORD dwCallBack; ... case MIM_OPEN: case MIM_CLOSE: case MIM_DATA: case MIM_LONGDATA: case MIM_ERROR: case MIM_LONGERROR: case MIM_MOREDATA: if (wDevID > MIDM_NumDevs) return;
dwCallBack = MidiInDev[wDevID].midiDesc.dwCallback; uFlags = MidiInDev[wDevID].wFlags; hDev = MidiInDev[wDevID].midiDesc.hMidi; dwInstance = MidiInDev[wDevID].midiDesc.dwInstance; break; ... DriverCallback(dwCallBack, uFlags, hDev, wMsg, dwInstance, dwParam1, dwParam2); } ---
So it gets truncated with a cast to DWORD it seems. You could easily check that modifying local dwCallBack variable to be DWORD_PTR, and you need to modify a driver you're using - winealsa or wineoss.
I'll send a patch for that later today if this change helps you.
http://bugs.winehq.org/show_bug.cgi?id=31507
--- Comment #6 from George Yohng georgewi@oss3d.com 2012-08-20 05:34:24 CDT --- I didn't check yet - this will require me to install the development package. Would it be an option if I send a test executable for you to check on your end?
From looking at the source code, I think that dwInstance variable will require
the same treatment, since in general a pointer is passed in it as well.
http://bugs.winehq.org/show_bug.cgi?id=31507
Eric Pouech eric.pouech@orange.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |eric.pouech@orange.fr
--- Comment #7 from Eric Pouech eric.pouech@orange.fr 2012-08-20 06:07:25 CDT --- there's other stuff to look at: - {mod,mid,wod,wid...}Message parameters should be DWORD_PTR - local variables (instance, callback) should be DWORD_PTR - there's still a couple of casts to DWORD that should be gotten rid off ... A+
http://bugs.winehq.org/show_bug.cgi?id=31507
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, win64
http://bugs.winehq.org/show_bug.cgi?id=31507
--- Comment #8 from Nikolay Sivov bunglehead@gmail.com 2012-08-21 20:20:56 CDT --- (In reply to comment #7)
- local variables (instance, callback) should be DWORD_PTR
This one is committed:
72452b10151085afc92c9bfb5f5d224d68dc2de8 d05757d29ae76f7b63898738c68b4efbf5e742b2 d96cd05efe8bbdd7a97a88fdc4be1139a65760c5
http://bugs.winehq.org/show_bug.cgi?id=31507
George Yohng georgewi@oss3d.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED
--- Comment #9 from George Yohng georgewi@oss3d.com 2013-07-04 07:51:41 CDT --- I tested the changes, all worked fine.
http://bugs.winehq.org/show_bug.cgi?id=31507
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #10 from Alexandre Julliard julliard@winehq.org 2013-07-12 13:47:54 CDT --- Closing bugs fixed in 1.6-rc5.