News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

...and a segfault.

Started by neroden, April 01, 2010, 05:31:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

neroden

When hitting "copy convoy", naturally.   *Before* setting a line on the to-be-copied convoi, IIRC.

This happens infrequently and is hard to reproduce.

Backtrace:
#0  schedule_t::get_aktuell (this=0xf205db0) at boden/../dataobj/fahrplan.h:72
#1  convoi_t::check_pending_updates (this=0xf205db0) at simconvoi.cc:3924
#2  0x081cf065 in convoi_t::set_line (this=0xf205db0, org_line=DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjuction with DW_OP_piece.
)
    at simconvoi.cc:3894
#3  0x081d6d22 in depot_t::copy_convoi (this=0xea858c8, old_cnv=...)
    at simdepot.cc:365
#4  0x0821fc41 in wkz_change_depot_t::init (this=0x0, welt=0xcf038a8,
    sp=0xd0b4ec0) at simwerkz.cc:5322
#5  0x08239aef in karte_t::local_set_werkzeug (this=0xcf038a8, w=0xf0df430,
    sp=0xd0b4ec0) at simworld.cc:2336
#6  0x081d5a51 in depot_t::call_depot_tool (this=0xea858c8,
    tool=<value optimized out>, cnv=..., extra=0x0) at simdepot.cc:138
#7  0x08109436 in depot_frame_t::action_triggered (this=0xf2040e8,
    komp=0xf204398, p=...) at gui/depot_frame.cc:441
#8  0x080de217 in gui_action_creator_t::call_listeners (this=0xf204398, v=...)
    at gui/components/../../ifc/gui_action_creator.h:36
#9  0x080dcceb in button_t::infowin_event (this=0xf204388, ev=0xbfffd274)
    at gui/components/gui_button.cc:337
#10 0x08120615 in gui_container_t::infowin_event (this=0xf2040ec,
    ev=0xbfffd2d0) at gui/gui_container.cc:93
#11 0x08121819 in gui_frame_t::infowin_event (this=0xf2040e8, ev=0xbfffd3c4)
    at gui/gui_frame.cc:89
#12 0x08108e3c in depot_frame_t::infowin_event (this=0xf2040e8, ev=0xbfffd3c4)
    at gui/depot_frame.cc:482
#13 0x08231d5b in check_pos_win (ev=0xbfffd4a0) at simwin.cc:938
#14 0x082561f8 in karte_t::interactive (this=0xcf038a8, quit_month=2147483647)
    at simworld.cc:5558
#15 0x082053e7 in simu_main (argc=1, argv=0xbffff434) at simmain.cc:1068
#16 0x0828f6ca in main (argc=1, argv=0xbffff434) at simsys_s.cc:743

The line with the segmentation fault seems harmless, so I've no idea what's wrong.

Bernd Gabriel

Reviewing the code I found that this error might happen, if the convoy exceeds you credit limit.
Then the new convoy has no vehicle, but needs at least one to create the new schedule.
Without a schedule get_aktuell() will produce the SegFault.

Did you get the "poor man's dialog" about the exceeded credit limit?
The journey is the reward!

jamespetts

Neroden,

thank you very much for your report, and Bernd, thank you for narrowing down the issue. It seems that the sensible fix would be to check whether the purchasing a new convoy would exceed one's credit limit before creating the new convoy object, and abort the process early if it does.
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.

neroden

Quote from: Bernd Gabriel on April 01, 2010, 11:24:51 PM
Reviewing the code I found that this error might happen, if the convoy exceeds you credit limit.
Then the new convoy has no vehicle, but needs at least one to create the new schedule.
Without a schedule get_aktuell() will produce the SegFault.
Seems likely -- I've been running in 1800-1830 which makes it very easy to blow through the credit limit.

jamespetts

Bernd,

did you fix this one in your branch, or do I need to look into this?
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.

Bernd Gabriel

This is not fixed.
I only changed copy_convoi() to remove the Trouble in the convoy copy code
You will fix it along with the reworked copy_convoi(), which then will buy the whole convoy or nothing.

BTW: a challenging task, as you must keep track of the already planned to use vehicles in depot. Current code does not ease this task.
You probably will add a method for getting the number of available suitable vehicles before actually getting them. Or the depot offers an "order sheet" (a list of all available vehicle types and quantity), on which you can remember, how many vehicles of which kind you reserved while checking affordability.
The journey is the reward!

jamespetts

Bernd,

thank you for the information - most helpful. I have managed to apply a quick fix that stops the crashes: it will copy as many vehicles as it can. If it copies no vehicles, it will abort the process without crashing. Copying no vehicles at all unless there is enough money to copy them all will take considerably more work - one for the "to do" cupboard, perhaps! Thank you both for your work on this.
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.