News:

SimuTranslator
Make Simutrans speak your language.

120.4.1 Crash on launch: NSRangeException

Started by brunoresende29, January 04, 2020, 01:53:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

brunoresende29

Hello
I'm getting a crash on launch on the latest available build on macOS. I tried looking for 121 but it doesn't seem to be available for Mac?
I'm running macOS 10.15.2 (19C57), and here is the stack trace:


2020-01-04 14:28:54.910 simutrans[70171:5061168] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 18446744073709551615 beyond bounds for empty array'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff3c05a8ab __exceptionPreprocess + 250
1   libobjc.A.dylib                     0x00007fff722cb805 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff3c1098ae _CFThrowFormattedException + 202
3   CoreFoundation                      0x00007fff3bf7b3d3 -[__NSArrayM objectAtIndex:] + 142
4   simutrans                           0x000000010e641e44 _ZN10vector_tplIPK14citycar_desc_tE9insert_atEjRKS2_ + 7284
5   simutrans                           0x000000010e5e2582 _ZN10vector_tplI14halt_dist_nodeE9insert_atEjRKS0_ + 3122
6   simutrans                           0x000000010e5d078d _ZNSt3__127__insertion_sort_incompleteIRPFb14quickstone_tplI9simline_tES3_EPS3_EEbT0_S8_T_ + 17325
7   simutrans                           0x000000010e5e2af5 _ZN10vector_tplI14halt_dist_nodeE9insert_atEjRKS0_ + 4517
8   libdyld.dylib                       0x00007fff736397fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    70171 abort      /Volumes/Horus/Simutrans/simutrans


Looks like an unsigned underflow to me  :laugh:

brunoresende29

Also, this happens on pak128, pak128.Britain, and pak128.german. On pak128 the game just quits, but on Britain and German I get the following errors:

Ters

Those last two messages are warnings. Some objects share a name, which means that only one of them will be available in the game. It is either due to incorrectly installed pak sets or add-ons, conflict between add-ons, or a fault in the pak set itself. Some pak sets are known to have such errors, but I don't remember which. These errors are old. Simutrans just started giving warnings about it relatively recently.

As for the crash: Does it crash immediately, during pak set loading, or during game loading (possibly auto loading of the auto saved game)?

brunoresende29

It happens during early launch, right after I select the pakset. The pakset loading screen then shows and it crashes right after that.

Ters

The exact cause of the error seems obvious: Something is trying to access the last item in an empty array.

What is not clear, is where this is happening. The "readable" parts of entry 4 through 7 are red herrings, although it is puzzling why those symbols are present in the executable, and not others. The use of NSArrayM suggests that it is in some OS X specific part of the code (unless whatever compiler has been used turn regular arrays into that), since that appears, from googling, to be an OS X thing. Someone who can debug on OS X, possibly with a debug build, is likely needed to track this down. Or someone with better psychic debugging skills.

DThunder518

This was happening to me too this week on my new Mac. It would happen right after selecting a language. Whenever I would launch the program, it would bring me to the language selection screen. This made me think that maybe it had to do with creating/saving an initial settings file. My solution was to copy ~/Library/Simutrans folder from my old mac to the new one, as well as the Simutrans folder with executable (same version) & paksets into the Applications folder. That worked. The old Mac is on an older version of Mac OS

Ters

Indeed. Poking around in a disassembly of the executable I found in the Simutrans for Mac zip, there is a call to chdir right before the array is allocated.

Ters

Of course, there are 52 chdir calls in Simutrans.

However, I think I have narrowed it down now. The crash is during MIDI initialization, based on the string constants referenced in that part of the code. dr_midi_stop lacks a check on nowPlaying in both Mac-backends, and can be called in some cases (depending on settings) from midi_set_mute, which is called during startup.

prissi

#8
Could you test the nightly for Mac at https://github.com/aburch/simutrans/releases/tag/Nightly

If am not sure the error has been solved in between (since I do not have a Mac), but please give it a try.

EDIT: This only happens, if -nomidi is set on the commandline. r8890 (or the nightly on 1.2.2020 in four hours) should fix this.

gummipunkt

Hi,

in your nightly the simutrans unix app is missing, if I copy them from the last stable release it failed with:

2021-02-04 07:31:25.252 simutrans[25684:2383166] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 18446744073709551615 beyond bounds for empty array'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff2048c6af __exceptionPreprocess + 242
1   libobjc.A.dylib                     0x00007fff201c43c9 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff20540a9a -[__NSCFString characterAtIndex:].cold.1 + 0
3   CoreFoundation                      0x00007fff203b3138 -[__NSArrayM objectAtIndex:] + 142
4   simutrans                           0x0000000102f0be44 _ZN10vector_tplIPK14citycar_desc_tE9insert_atEjRKS2_ + 7284
5   simutrans                           0x0000000102eac582 _ZN10vector_tplI14halt_dist_nodeE9insert_atEjRKS0_ + 3122
6   simutrans                           0x0000000102e9a78d _ZNSt3__127__insertion_sort_incompleteIRPFb14quickstone_tplI9simline_tES3_EPS3_EEbT0_S8_T_ + 17325
7   simutrans                           0x0000000102eacaf5 _ZN10vector_tplI14halt_dist_nodeE9insert_atEjRKS0_ + 4517
8   libdyld.dylib                       0x00007fff20335631 start + 1
9   ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
zsh: abort      /Applications/simutrans\ 2/simutrans
Saving session...
...copying shared history...
...saving history...truncating history files...

Dwachs

For some reasons, no zip files are generated over there. You might give the compiles from https://github.com/Andarix/simutrans/releases a try.
Parsley, sage, rosemary, and maggikraut.

gummipunkt

Quote from: Dwachs on February 04, 2021, 07:05:33 AM
For some reasons, no zip files are generated over there. You might give the compiles from https://github.com/Andarix/simutrans/releases a try.

Hi, there's also no excutable simutrans unix file.


gummipunkt

Quote from: Dwachs on February 04, 2021, 10:26:34 AM
https://github.com/Andarix/simutrans/releases/download/Nightly/simulinux-x64-nightly.zip

another one is on

https://www.simutrans-forum.de/nightly/

no, it's not there. if i copy it from V120.2.2 into the nightly folder:

  Reading MIDI file '/Users/gummi/Downloads/simutrans 4/music/51-Summer-Intersection.mid' - Summer Intersection
  Reading MIDI file '/Users/gummi/Downloads/simutrans 4/music/52-Dreamy-Oriental-Nights.mid' - Dreamy Oriental Nights
Midi disabled ...
2021-02-04 12:36:33.117 simutrans[28292:2520349] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 18446744073709551615 beyond bounds for empty array'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff2048c6af __exceptionPreprocess + 242
1   libobjc.A.dylib                     0x00007fff201c43c9 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff20540a9a -[__NSCFString characterAtIndex:].cold.1 + 0
3   CoreFoundation                      0x00007fff203b3138 -[__NSArrayM objectAtIndex:] + 142
4   simutrans                           0x000000010e095244 _ZN10vector_tplIPK14citycar_desc_tE9insert_atEjRKS2_ + 7348
5   simutrans                           0x000000010e033f12 _ZNSt3__127__insertion_sort_incompleteIRPFbPK6tool_tS3_EPPS1_EEbT0_S9_T_ + 30754
6   simutrans                           0x000000010e0221f7 _ZNSt3__127__insertion_sort_incompleteIRPFb14quickstone_tplI9simline_tES3_EPS3_EEbT0_S8_T_ + 16039
7   simutrans                           0x000000010e034455 _ZNSt3__127__insertion_sort_incompleteIRPFbPK6tool_tS3_EPPS1_EEbT0_S9_T_ + 32101
8   libdyld.dylib                       0x00007fff20335631 start + 1
9   ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Dwachs

???? These zip files contain an executable named 'simutrans' !!!
Parsley, sage, rosemary, and maggikraut.

prissi

First: The error in question is a MacOS error. Why are we discussing Linux?

Second: https://github.com/aburch/simutrans/releases/tag/Nightly has the latest MacOS, including an executable.

Third: the above trace fails after vector_tpl<citycar_desc_t>::insert_at which is different from the midi error. However, if you start an old version after running a new one, it is a clever idea to remove default.sve and settings.xml from you personal simutrans folder.

Andarix

https://github.com/Andarix/simutrans/releases/download/Nightly/simumac_SDL2-nightly.zip

This file contains a folder simutrans.app, where there is also a program file (simutrans.app \ Contents \ MacOS \ simutrans).



I just see that it even contains the pak64 graphics set (pak folder).

Unfortunately I have no idea about MacOS.

gummipunkt

Quote from: Andarix on February 04, 2021, 02:09:08 PM
https://github.com/Andarix/simutrans/releases/download/Nightly/simumac_SDL2-nightly.zip

This file contains a folder simutrans.app, where there is also a program file (simutrans.app \ Contents \ MacOS \ simutrans).



I just see that it even contains the pak64 graphics set (pak folder).

Wow, Thanks that's it. I've to open the .app file. Wow sorry this I hadn't to made one single time in the last eight years.

Thanks a lot, this was the right way to get it to work.!

prissi

You should not have to open the app file. Doubleclicking the simutrans bundle shoudl work. Which version of MacOS is this?

Also, does the official release do nopt work as well?  https://github.com/aburch/simutrans/releases/tag/Nightly

Dwachs

Quote from: prissi on February 05, 2021, 06:22:52 AM
Also, does the official release do nopt work as well?  https://github.com/aburch/simutrans/releases/tag/Nightly
These are not so 'nightly' as the name suggests. It seems that the upload-action is only triggered if the corresponding tag is pushed. I will look into this.
Parsley, sage, rosemary, and maggikraut.

gummipunkt

Quote from: prissi on February 05, 2021, 06:22:52 AM
You should not have to open the app file. Doubleclicking the simutrans bundle shoudl work. Which version of MacOS is this?

Also, does the official release do nopt work as well?  https://github.com/aburch/simutrans/releases/tag/Nightly

Doubleclick on the .app doesn't help, it close down immediately. I have MacOS Big Sur.

The official release doesn't work, please see above. Anything with broken midi or something like this.

Best,
Patrick

prissi

The official release from sourceforge is broken, I think. But the nightly was reported once as working last autumn. Maybe the last OS update again broke things. Apple does not like programs built on older OS very much,

Roboron

Quote from: gummipunkt on February 05, 2021, 07:00:00 AMThe official release doesn't work, please see above. Anything with broken midi or something like this.

I run into this very same problem when testing for the Steam release

QuoteInitial tests show that Simutrans crashes if music is enabled (although it can be just my VM). Just in case, I have forced the "-nomidi" option for everyone, but you can enable music from in-game settings. We will solve this later.

So yes, currently the games crashes on Mac OS if MIDI is enabled. Disabling the MIDI should work.

prissi

@Dwachs
The aburch like has the nightlies. But github never updates the upload date or the tag. One would have to create a new release every day otherwise, without a static link.

So is it enough to set the default mid playback to off in env_t then for MacOS? Please test nightly 9603

Ters

Quote from: prissi on February 04, 2021, 12:52:02 PM
Third: the above trace fails after vector_tpl<citycar_desc_t>::insert_at which is different from the midi error.

Don't pay any attention to the symbol names in stack traces when the number behind them is more than a few hundred (unless you know the function is really huge). The executable clearly doesn't have symbols for all the functions. If it did, simmain, or one of the thread entry points, would be listed. The stack trace generator just keeps going backwards in memory until it finds a symbol. That might have nothing to do with the code that crashed. It can also change from build to build.

prissi

#25
The sript tagging rename on github still not works as expected. (But thanks Dwachs for trying, I tried that a year ago or so also a lot.)

ceeac

Quote from: prissi on February 07, 2021, 01:20:24 PMThe sript tagging rename on github still not works as expected.
Tried to correct the revision extraction code in r9612.

Dwachs

Now the name is correct, but it says 'released 2 days ago', which is not correct. These github actions are a mess.
Parsley, sage, rosemary, and maggikraut.

prissi

If the zip files are correct, maybe just calling in Nightly is enough. And I agree, the github/actions could be improved. Especially uploads should not be that complicated, since this the whole point of frequent builts.

Roboron

The crash happens when AVFoundation is going to play the midi (player play - line 17).

Everything seems ok, currentposition is 0, the song to play is number 47 of 49... But it crash anyway.

While I don't know how AVFoundation works to solve this, we can avoid the crash introducing error handling. The following patch just add a try/catch to player play and nothing more. This prevents the game from crashing when unmuting / enabling music.

EDIT: prissi you may better revert your commit, it is not needed if this is incorporated

TurfIt

Does it just crash on these GS songs?  i.e. Songs 47-50, 52 are GS, not GM. Perhaps AVF can't handle that format?
Also, there's 52 songs currently listed, why is it seeing 49?

Roboron

Quote from: TurfIt on February 09, 2021, 06:38:05 PMDoes it just crash on these GS songs?

No, it crash with every song.

Quote from: TurfIt on February 09, 2021, 06:38:05 PMAlso, there's 52 songs currently listed, why is it seeing 49?

Initially tested with Extended because I was porting recent Mac fixes to Extended. Extended has 3 less songs, apparently.

prissi

Quote from: Roboron on February 09, 2021, 06:15:29 PMprissi you may better revert your commit, it is not needed if this is incorporated
Which one are you referring too?
Since I do not have a Mac, I can just submit whatever is sent to me. Thus I put your in r9626

Roboron

Quote from: prissi on February 12, 2021, 02:10:26 AMWhich one are you referring too?

I mean this one (r9603), since it is not needed because the crash is "solved".

prissi