BloodRayne@Posted: Sun Apr 02, 2006 8:31 am :
At seemingly random points my Ultimate Mod is crashing. I have 99% of it in place but for these damned crashes. I've been searching THREE weeks for this bug and I've commented out almost every single piece of code for my mod and still... it crashes at random moments with a 'cannot read from memory error'.

I'm pretty much losing my patience with it; does anybody know what kind of script can cause a 'cannot read from memory' error? I'll post up a screenshot of the error as soon as I manage to recreate it.

Some things I do know:
- It doesn't happen in the mainmenu (I can leave that running for hours no probs).
- It does happen in the mainmenu after starting a game.
- It happens at random times (not right after a creature dying or something like that). I can quickload a game; not touch the mouse for 10 minutes then BANG it crashes without me ever touching the mouse.
- It doesn't happen with any other mod I've made on the same executable (i.o.w. it's only with the Ultimate mod).

I'm not willing to post all my code here (because almost every script file in the game was altered in one way or another). What I would like to do is pass the mod over to anyone with skills to see if they can find out what's wrong (here's looking at you PBMax ;) ).

So if anybody ever ran into this sort of problem, can you let me know so I'll know better what to look for?

Thanx in advance, guys!

edit: Attached a screenshot
Image



The Happy Friar@Posted: Mon Apr 03, 2006 2:30 am :
ok, this HAS happened to me with my Last STand mod once or twice. I belive it had to do with a loop somewhere. IE it wasn't detected as infinite but it WAS infinite.



BloodRayne@Posted: Mon Apr 03, 2006 9:48 am :
Thanks for your answer. I've been checking the code, it's based on a loop, but I don't see how it could be a 'runaway' loop. It's basically something like this.

Code:
Void ult_loop {
    while (1) {
        (...code that calls a thread on ai_player...)
        sys.waitframe();
    }
}


You may ask yourself why I did this. It's because the _init event is not called from ai_player.script when you load a game (it basically skips the entire init event which sucks). Otherwise I'ld just make a loop in there.

But I don't see how that loop could cause the error; many scripts in D3 use the same way of looping. Before I just called the thread on AI_Player in the (idle) loop of the legs and some other idle loops for the player but then the ccrash happened as well.

In fact, all this mess started when I added my own custom windowdef to the hud.gui file. Strange this is that when I take out the code that sets the guiparm (and use the original hud) the crash still happens.

But...the error is the exact same as when I make a gui that has an empty variable.
I basically edited all the SP maps to make the start entities into "$info_player_start1" then I use the setGuiParm command to set it's width (sort of like a stamina meter).

So I'm basically back to square 1.

I'ld like to start a process of elimination and simply comment out all of my scripts and see when the crash starts to happen after uncommenting them but that's almost undoable because it sometimes takes 20 minutes before it crashes. With all the scripts in the mod it would take weeks before I can test everything.



The Happy Friar@Posted: Mon Apr 03, 2006 1:59 pm :
calling the thread on AI player may be the problem. I put a script in that check zombie settings & sometimes it wouldn't work properly. Just sometimes for me though. I don't have the old script to look at anymore as I got it working a month or so ago. :(



BloodRayne@Posted: Mon Apr 03, 2006 3:17 pm :
The Happy Friar wrote:
calling the thread on AI player may be the problem. :(

I wish it was!

But the thing is that this method was working fine before I added the gui. :o
Technically speaking this error occurs when the game is trying to access a memory area that's not accesable (e.g. empty).

This happens when you reference a variable that doesn't exist etc..etc.. I've checked all places where there's variables and everything is 'filled'. But the fact that it is happening randomly does suggest a problem with the loop somewhere.

[edit] damn I wish I could be more specific. :(



The Happy Friar@Posted: Mon Apr 03, 2006 4:19 pm :
are you sure the variable ALWAYS exists?

Maybe ou could post the GUI? If it's caused by that guie then it would happen to others.



BloodRayne@Posted: Mon Apr 03, 2006 4:29 pm :
Ok, gui code... here goes. :)

But I really think that this code is solid and bugfree. In each SP map, I've renamed the player start entities to 'info_player_start_1' and the reference works; the gui responds predictibly.

This event is fired upon the monster_killed(); event.
Code:

if ( something != 1 ){
   if (someValue < 10 ) {
      someValue = someValue + 1;
   }   
   if ( someValue < 0 ) {
      someValue = 0;
   }

   $info_player_start_1.setGuiParm( "someValue", someValue );

}


Then the gui, this is inside hud.gui:
Code:
        windowDef Something
   {
      rect 10, 413, 142,25
      visible   1
      background   "gui/ult/tdd"
      noevents   1

      windowDef bkg_something
      {
         noevents   1
         rect      65, 7, ( "gui::someValue" * 7 ), 7
         forecolor   0.8 ,1 ,1 ,1
         background   "gui/ult/tdd_fill"
         visible      1
      }
   }



pbmax@Posted: Mon Apr 03, 2006 6:51 pm :
BloodRayne wrote:
What I would like to do is pass the mod over to anyone with skills to see if they can find out what's wrong (here's looking at you PBMax ;) ).


i'm certainly not any more skilled than you are. the only thing i could offer is a second pair of eyes to catch something you may have overlooked.


here's a few thoughts:

-run each weapon mod alone one at a time to narrow it down (and hopefully its not a combination of weapon mods). i know it would take a long time, but you already have 3 weeks invested into it.

-perhaps its limited to your computer configuration? let another person run it for a few hours to see if it happen on thier machine.

-you must have a ton of variables. are all of them uniquely named from your other variables and id's?



BloodRayne@Posted: Tue Apr 04, 2006 8:08 pm :
Thanks. :)

It wasn't in the weaponry. The bulk of the code of the mod is in ai_player.script which made me squeel and look over that script over and over again. Until I remembered to look at the original loop that I made, which let me to a litte surprise. Look at the code below and guess what's wrong. ;)

Code:
void ultLoop() {
   float    framWatta;
   
   framWatta = 0;
   while ( 1 ) {
      framWatta = framWatta + 1;
      if ( framWatta > 10 ) {
               $player1.callFunction( "checkir" );
      }
      sys.waitFrame();
   }
}


hehe... heheheee.... *slaps head*
Ok so you've propably noticed already... I made a runaway variable lol.
framWatta the float was just growing and growing as I forgot to reset it to 0 after each check was made. D'OOOOOHHH!!

so I fixed it:
Code:
void ultLoop() {
   float    framWatta;
   
   framWatta = 0;
   while ( 1 ) {
      framWatta = framWatta + 1;
      if ( framWatta > 10 ) {
               $player1.callFunction( "checkir" );
                         framWatta = 0;     //let it be eternally noted that BR is a dumbass
      }
      sys.waitFrame();
   }
}


:x:D



pbmax@Posted: Tue Apr 04, 2006 8:45 pm :
so where did you put that code exactly?



rich_is_bored@Posted: Wed Apr 05, 2006 5:36 am :
I like your comments. :)



BloodRayne@Posted: Wed Apr 05, 2006 6:55 am :
pbmax wrote:
so where did you put that code exactly?

I made a scripfile called 'ultimate_funcs.script' and make a reference to it via doom_main.script so the functions and objects are available. In there is the ult_loop script.

Because Cvars aren't stored in savegames I use it as a cheap hack to see if all my variables have been initialised. So I have a cvar called 'ult_initialised' and if it's anything other than '1' then I re-initialise the vars and in that initialisation loop I also call the ult_loop script.

I really, really, really thought that the runaway variable was the cause of the crash; so after posting my eureka I went and played the mod thinking it wouldn't crash. It didnt; for the first 20 minutes then the dreaded 'cannot read from memory' error propped up again.

PB: Can I upload the mod as a zip file so you could take a look at it?

rich_is_bored wrote:
I like your comments. :)

It's the truth; and I can't handle it baby!



pbmax@Posted: Wed Apr 05, 2006 2:15 pm :
sure. i can't promise anything though...



Giganoto@Posted: Tue Oct 03, 2006 11:05 am :
This is a very late reply, but I'm at work and feel more like modding than working :p So I'm reading through the forum a bit...

A suggestion: start using a version control system :-) Ya even for a mod... Best way to fall back on previous versions to detect which modifications caused the error.
PS: I ain't using any atm neither. But I'm just still a noob modder, this will change tho :-P

Is this solved yet? If it isn't, I wouldn't focus on "the gui being the cause" thing. It happens after about 20 minutes, so it could have been easily overlooked in previous tests...