The International Simutrans Forum

 

Author Topic: [dingliste-cleanup] Crash on removing factory  (Read 973 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 19823
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
[dingliste-cleanup] Crash on removing factory
« on: June 20, 2013, 09:57:43 AM »
On removing any factory, either by it closing down automatically or being bulldozed by the public player, I get an access violation in slist_tpl_t, which is caused by the following code:

Code: [Select]
if(plan) {

        // we need a copy, since the verbinde fabriken is modifying the list
        halthandle_t list[48];
        const uint8 count = plan->get_haltlist_count();
        assert(count<48);
        memcpy( list, plan->get_haltlist(), count*sizeof(nearby_halt_t) );
        for( uint8 i=0;  i<count;  i++  ) {
            // first remove all the tiles that do not connect
            plan->remove_from_haltlist( this, list[i] );
            // then reconnect
            list[i]->verbinde_fabriken();
        }

in simworld.cc calling
Code: [Select]
list[i]->verbinde_fabriken(); when
Code: [Select]
list[i]is an invalid (but not null) pointer.

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
Re: [dingliste-cleanup] Crash on removing factory
« Reply #1 on: June 22, 2013, 07:48:58 PM »
Very interesting.  Factory deletion is working fine for me on the mail-revenue branch.  Please try the ncn-devel branch; I suspect it is working there too.  I am getting crashes on the dinglist-cleanup branch...

The dinglist changes are very tricky and I want to understand them better before merging them.  I did not want you to merge my dinglist-cleanup branch, but you merged it by accident because I failed to upload dinglist-cleanup-light.

I strongly suggest that you rebranch -- start a new working branch -- from the point *before* you merged my dinglist-cleanup branch.  Then
(1) merge my ncn-devel branch, which is in relatively good shape apart from the bugs in the ticker display.
(2) cherry-pick any individual fixes which you made (you can go through them in the "network" graph on the github website).

We can merge dinglist-cleanup after we better understand the problem.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 19823
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [dingliste-cleanup] Crash on removing factory
« Reply #2 on: June 23, 2013, 04:36:23 PM »
I have fixed this - it was actually a simpler problem than first anticipated: the dud pointers came from a halthandle, which can be bounds checked, and also appeared in versions other than dingliste-cleanup.