FS#3648 - [OSX] Crash with selecting music

Attached to Project: OpenTTD
Opened by Ingo von Borstel (planetmaker) - Friday, 26 February 2010, 21:04 GMT
Last edited by Remko Bijker (Rubidium) - Friday, 13 August 2010, 10:59 GMT
Type Bug
Category Core
Status Closed
Assigned To No-one
Operating System Mac OS X
Severity Medium
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


trunk r19268

How to reproduce:
Unpack the attached music set in your personal gm dir (~/.openttd/gm or here ~/Documents/OpenTTD/gm)
Start the game, select OpenMSX-r4 and then start or load a map
Select the jukebox and then programme
Programme such that "Little Blue Box Car" is not the only one. When that song is about to be played, OpenTTD crashes (see attached files). With a sequential order and skip tracks I managed to mess up such that the crash message window showed, but OpenTTD hung there, to be "kill -9"ed only.
This task depends upon

This task blocks these from closing
 FS#2782 - [OSX] Port hopelessly outdated 
Closed by  Remko Bijker (Rubidium)
Friday, 13 August 2010, 10:59 GMT
Reason for closing:  Requested by user
Comment by Remko Bijker (Rubidium) - Friday, 26 February 2010, 22:01 GMT
  • Field changed: Summary (Crash with selecting music → [OSX] Crash with selecting music)
  • Field changed: Status (New → Not confirmed)
I can't reproduce it on Linux, Yexo can't reproduce it on Windows. The crash log is completely, excluding the crash logger, somewhere in Apple's code. This means it's very likely that the bug is in Apple's code.
Comment by Patrick (Chakotay) - Monday, 08 March 2010, 18:31 GMT
Manged to reproduce it on Mac OS X 10.6.2 with rev 19374.
I just let OpenTTD run with the music on in the background.
After 5 minutes or so, it crashed repeatedly somewhere deep in CoreAudio.
Comment by Ingo von Borstel (planetmaker) - Sunday, 21 March 2010, 08:56 GMT
Indeed. With a bit of patience this happens also out of the blue without any user interaction (r19318)
Comment by Patrick (Chakotay) - Tuesday, 13 April 2010, 11:29 GMT
rev. 19615

Tested it again today with Mac OS X 10.6.3 and the latest development tools (Xcode 3.2.2) from Apple.
Doesn't seem to happen anymore. Let all the songs play through about 2 times.

Might have been fixed in update to 10.6.3?
Does it still occur with anyone using that version?
Comment by Mathew Eis (matheweis) - Sunday, 02 May 2010, 04:28 GMT
I just tested with Mac OS X 10.6.3 and Xcode 3.2.2, and was able to replicate the crash, so it does not appear to have been fixed. I tested both 1.0.1 and r19750.

Of note, I was able to replicate it much more easily by quickly cycling between songs. If I waited until the songs changed by themselves it only happened once.
Comment by Mathew Eis (matheweis) - Sunday, 02 May 2010, 09:31 GMT
I spent some time extensively looking into this bug this afternoon, and came to the following two conclusions:

1) The MIDI file LittleBlueBoxCar.mid is almost certainly corrupt.

The audio sounded significantly different in three different MIDI players that I tested it with. Also, I own a copy of Logic Express, and when attempting to import the file to look at the notes, I was informed of a "Data conflict while reading Track 2".

2) Corrupted MIDI file aside, there IS a bug in the Mac OS CoreAudio.

I wrote up a 40 line test application that loaded and played the midi file, so we could eliminate all the other factors. If the program was run with DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib, it crashed immediately and consistently on a memory overflow deep in Core Audio... but ONLY on the one midi file. All others did not crash the program. I've attached the program if you want to look it over.

I went ahead and filed a bug report with Apple (Problem ID 7932088), but I have no idea how long that process will take.

Only two things come to mind as far as solutions - neither are very elegant, but I will just throw them out there:
a. Call it good and move on, since the midi file was almost certainly corrupted
b. Implement some alternative pre-parsing of midi files to ensure validity of the files before feeding them to the OS.

Comment by Ingo von Borstel (planetmaker) - Thursday, 12 August 2010, 16:31 GMT
So... as windows driver crashes are not a bug. Is this then not a bug either? The song doesn't exist anyway anymore within OpenMSX...
Comment by Mathew Eis (matheweis) - Wednesday, 17 November 2010, 04:53 GMT
I realized this bug has been closed, but for reference, Apple has responded to my bug report, and (I have verified) has fixed the CoreAudio bug as of Mac OS X 10.6.5