Crash when doing a lot of fetching in ZScript

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Crash when doing a lot of fetching in ZScript

Post by Accensus »

Versions: GZDoom 3.1.0 and GZDoom g3.2pre-119-gac811f9
Both are x64.

What I have attached below is a HUD, but it has no graphics. Everything has been stripped to pinpoint the issue. Keep in mind that due to the nature of the error I had to make a lot of CVARs! (135 to be precise. No more, no less.) I suggest to backup your ini or burn it afterwards.

So, onto the point. What happens is that whenever I'd run the game, it'd crash. However, if you open up ZScript.txt and comment out any line in void UpdateKills(), there will be no crash on start-up. What I did may be a clear case of "Don't do that!", in which case I'd love to hear a suggestion on how to update variables. It's only a mere guess that adding some sort of a delay between calls to UpdateKills() and doing checks periodically would be a better idea, but I haven't tried that yet.

EDIT: Attached CrashReport, for what it's worth.
Attachments
CrashReport.zip
(19.2 KiB) Downloaded 20 times
CrashWad.wad
(14.38 KiB) Downloaded 22 times
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Crash when doing a lot of fetching in ZScript

Post by Graf Zahl »

The crash occurs when the function accumulates more than 255 integer constants. I guess that the opcode to read a constant isn't working properly.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Crash when doing a lot of fetching in ZScript

Post by Graf Zahl »

Fixed. The check for handling this was wrong for one particular opcode that got used here.
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: Crash when doing a lot of fetching in ZScript

Post by Accensus »

Amazing. Thank you!

Is there an actual limit of how many variables one can have? And would 170 assignment operations almost each tic lag out?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Crash when doing a lot of fetching in ZScript

Post by Graf Zahl »

Assignment operations are cheap. The biggest time waster in your code would be the (native) lookup of the actual CVARs and not the VM code.
Regarding limits. The available resources per function are:

- 32767 integer constants
- 32767 string constants
- 32767 float constants
- 32767 address constants (this includes all function addresses, RNGs or other native resources being referenced.)
- 256 integer registers
- 256 floating point registers
- 256 string registers
- 256 address registers
Note that registers and local variables are not equivalent. Some registers are needed for intermediate results and arrays and structs are allocated on the stack, not in registers.
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: Crash when doing a lot of fetching in ZScript

Post by Accensus »

This is very useful to know. Thank you once again.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Crash when doing a lot of fetching in ZScript

Post by Major Cooke »

I've made a dedicated page to ensure this information isn't lost.

However, by native resources, is that just functions or are properties included?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Crash when doing a lot of fetching in ZScript

Post by Graf Zahl »

That's local resources per function. Classes are stored elsewhere in memory and are not affected by this.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Crash when doing a lot of fetching in ZScript

Post by Matt »

Are these limits for every named or anonymous function being called?

Like, if I have a A_ABC() inside which there's a A_XYZ() call, do each of them have their own limit (i.e., I can have up to 256 address registers in A_XYZ without using up A_ABC's limit)

Also, is an "address register" like a pointer?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Crash when doing a lot of fetching in ZScript

Post by Graf Zahl »

Each function gets its own set of registers. And yes, an address register is effectively a pointer.
Post Reply

Return to “Closed Bugs [GZDoom]”