News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

Crash (segfault) shortly after opening simutrans-experimental

Started by gbm, December 25, 2011, 03:06:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gbm

I am using the latest Pak-Britain experimental release for this testing. I have been using the Github version of Experimental. I think I am having the same (segfault) problem as dustNbone in this thread:
http://forum.simutrans.com/index.php?topic=8400.msg79063#msg79063

I have been experiencing seg faults shortly after opening Experimental (it is crashing on the default 'demo' file that loads when you start it up). Running in gdb for a backtrace shows the crash is on line 158 of simconvoi.h (in the commit described below). The stack trace is:

#0  0x082429e2 in increment_way_distance (this=0xf00bef0, steps=4) at simconvoi.h:158
#1  convoi_t::increment_odometer (this=0xf00bef0, steps=4) at simconvoi.cc:749
#2  0x0830f677 in vehikel_basis_t::fahre_basis (this=0xf00ce68, distance=20404) at vehicle/simvehikel.cc:386
#3  0x08245ce8 in convoi_t::sync_step (this=0xf00bef0, delta_t=45) at simconvoi.cc:948
#4  0x082da6c7 in karte_t::sync_step (this=0xea6b358, delta_t=45, sync=true, display=true) at simworld.cc:2975
#5  0x0828b286 in interrupt_check (caller_info=0x835a227 "simworld.cc:6000") at simintr.cc:101
#6  0x082f3a54 in karte_t::interactive (this=0xea6b358, quit_month=2147483647) at simworld.cc:6459
#7  0x082955af in simu_main (argc=1, argv=0xbfffe744) at simmain.cc:1270
#8  0x083349d9 in main (argc=1, argv=0xbfffe744) at simsys_s.cc:682

I performed a bisection in git which determined that the first 'bad' commit was
                4418b0652f8a0a1df0c26d82eed94471e6c5c210     ADD: Air and seaport charges for using other players' facilities.

Changing line 117 of simconvoi.h so that accumulated_distance_since_departure is allocated to MAX_PLAYER_COUNT + 2 made the crashes go away (at least for the 'bad' commit). I do not however have any idea what the implications of this change are.

(simconvoi.h line 117)            uint32 accumulated_distance_since_departure[MAX_PLAYER_COUNT + 1];

(simconvoi.h lines 156-159)
                void increment_way_distance(uint8 player, uint32 steps)
                {
                        accumulated_distance_since_departure[player] += steps;           ****** CRASH *******
                }

Thanks for developing Simutrans Experimental :)

PS Merry Christmas :)

jamespetts

Gbm,

thank you for your very detailed and helpful bug report, and sorry that you are having trouble with Experimntal. I am currently staying with my parents for Christmas without easy access to my development environment, so shan't be able to look at this until I get back, but I am very grateful for such a well-written bug report. I hope that you are able to enjoy Experimental despite this bug, and merry Christmas!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

jamespetts

I am now home again, and able to test this. A brief initial run of the Windows debugging version does not show crashes in the demo game - that suggests to me that there is some undefined behaviour somewhere that is not showing with a debug build. I know that I was getting crashes on a Linux release build when I was away, but was unable to debug that. I shall investigate further and revert.

Edit: I think that I might have found the problem, and pushed a fix to the 10.x branch of my Github repository. (The problem was that I removed part of an unfinished feature in the commit to which you make reference above, but forgot to remove a small part of it that referenced MAX_PLAYER_COUNT + 1, which is an invalid memory location) I cannot test this properly, as the crash did not occur under Windows; are you able to check to see whether the crash has been fixed?

Thank you very much for your report.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

gbm


jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.