The International Simutrans Forum

 

Author Topic: 120.4.1 Crash on launch: NSRangeException  (Read 2900 times)

0 Members and 1 Guest are viewing this topic.

Offline brunoresende29

  • *
  • Posts: 19
    • Personal Website
  • Languages: EN, PT
120.4.1 Crash on launch: NSRangeException
« on: January 04, 2020, 01:53:37 PM »
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:

Code: [Select]
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:

Offline brunoresende29

  • *
  • Posts: 19
    • Personal Website
  • Languages: EN, PT
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #1 on: January 04, 2020, 02:19:45 PM »
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:

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5689
  • Languages: EN, NO
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #2 on: January 04, 2020, 07:22:58 PM »
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)?

Offline brunoresende29

  • *
  • Posts: 19
    • Personal Website
  • Languages: EN, PT
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #3 on: January 04, 2020, 10:27:08 PM »
It happens during early launch, right after I select the pakset. The pakset loading screen then shows and it crashes right after that.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5689
  • Languages: EN, NO
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #4 on: January 05, 2020, 11:01:14 AM »
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.

Offline DThunder518

  • *
  • Posts: 24
  • Languages: EN
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #5 on: January 29, 2020, 09:53:54 AM »
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

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5689
  • Languages: EN, NO
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #6 on: January 31, 2020, 11:38:47 AM »
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5689
  • Languages: EN, NO
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #7 on: January 31, 2020, 11:59:16 AM »
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #8 on: January 31, 2020, 12:00:47 PM »
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.
« Last Edit: January 31, 2020, 12:26:33 PM by prissi »

Offline gummipunkt

  • *
  • Posts: 5
  • Languages: EN, DE
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #9 on: February 04, 2021, 06:32:22 AM »
Hi,

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

Code: [Select]
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...

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4854
  • Languages: EN, DE, AT
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #10 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.

Offline gummipunkt

  • *
  • Posts: 5
  • Languages: EN, DE
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #11 on: February 04, 2021, 09:39:24 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4854
  • Languages: EN, DE, AT

Offline gummipunkt

  • *
  • Posts: 5
  • Languages: EN, DE
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #13 on: February 04, 2021, 11:37:57 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:

Code: [Select]
  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

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4854
  • Languages: EN, DE, AT
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #14 on: February 04, 2021, 12:43:58 PM »
???? These zip files contain an executable named 'simutrans' !!!

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #15 on: February 04, 2021, 12:52:02 PM »
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.

Offline Andarix

  • *
  • Posts: 252
  • Languages: de
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #16 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).

Unfortunately I have no idea about MacOS.

Offline gummipunkt

  • *
  • Posts: 5
  • Languages: EN, DE
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #17 on: February 04, 2021, 02:16:17 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.!

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #18 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

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4854
  • Languages: EN, DE, AT
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #19 on: February 05, 2021, 06:50:51 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.

Offline gummipunkt

  • *
  • Posts: 5
  • Languages: EN, DE
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #20 on: February 05, 2021, 07:00:00 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

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #21 on: February 05, 2021, 08:26:27 AM »
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,

Offline Roboron

  • Devotee
  • *
  • Posts: 245
    • Las Galácticas Aventuras de Komoyo Diga
  • Languages: ES, EN
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #22 on: February 05, 2021, 03:19:24 PM »
The 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

Quote
Initial 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #23 on: February 06, 2021, 12:21:37 PM »
@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

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5689
  • Languages: EN, NO
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #24 on: February 06, 2021, 01:53:47 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
github actions
« Reply #25 on: February 07, 2021, 01:20:24 PM »
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.)
« Last Edit: February 08, 2021, 07:06:38 AM by Dwachs »

Offline ceeac

  • Devotee
  • *
  • Posts: 238
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #26 on: February 07, 2021, 05:02:47 PM »
The sript tagging rename on github still not works as expected.
Tried to correct the revision extraction code in r9612.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4854
  • Languages: EN, DE, AT
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #27 on: February 08, 2021, 07:06:00 AM »
Now the name is correct, but it says 'released 2 days ago', which is not correct. These github actions are a mess.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #28 on: February 08, 2021, 02:04:39 PM »
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.

Offline Roboron

  • Devotee
  • *
  • Posts: 245
    • Las Galácticas Aventuras de Komoyo Diga
  • Languages: ES, EN
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #29 on: February 09, 2021, 06:15:29 PM »
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

Offline TurfIt

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 1431
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #30 on: February 09, 2021, 06:38:05 PM »
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?

Offline Roboron

  • Devotee
  • *
  • Posts: 245
    • Las Galácticas Aventuras de Komoyo Diga
  • Languages: ES, EN
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #31 on: February 09, 2021, 07:20:32 PM »
Does it just crash on these GS songs?

No, it crash with every song.

Also, 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #32 on: February 12, 2021, 02:10:26 AM »
prissi 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

Offline Roboron

  • Devotee
  • *
  • Posts: 245
    • Las Galácticas Aventuras de Komoyo Diga
  • Languages: ES, EN
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #33 on: February 12, 2021, 12:53:11 PM »
Which one are you referring too?

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

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10539
  • Languages: De,EN,JP
Re: 120.4.1 Crash on launch: NSRangeException
« Reply #34 on: February 12, 2021, 01:45:38 PM »
Ah yes, midi is activated again in r9631