• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Game hard crashes with show_message and structs

Hello1423

Member
I am very confused by an issue I am running into involving structs.

Basically, I would like to show some structs as text(for debugging), but sometimes using show_message on a struct causes a hard crash.

Here is some code that crashes my game instantly without any error log.

Code:
show_message("test 1")
if is_struct(_current){
    show_message("test 2")
    show_message(_current.x)
    show_message("test 3")
    show_message(_current)
    show_message("test 4")
}
It shows tests 1, 2, the correct x value, and 3, but not test 4. Instead, it hard crashes. Usually, show_message works just fine with structs as expected, but not now for some reason.

Does anyone have any idea why?
 

Evanski

Raccoon Lord
Forum Staff
Moderator
_current.x

is most likely the issue as unless it is an object and not a struct I highly doubt you have x as your own variable without game maker yelling and screaming at you that its wrong
 
Last edited:

Yal

šŸ§ *penguin noises*
GMC Elder
Try show_message(string(struct.variable)) instead, so you're guaranteed a writeable representation.
 

kburkhart84

Firehammer Games
_current.x

is most likely the issue as unless it is an object and not a struct I highly doubt you have x as your own variable without game maker yelling and screaming at you that its wrong
That would be wrong...they confirmed it was a struct before the event...AND, yes you CAN have x for a variable in a struct. You can also have pretty much any of the built-in variables. See this manual page for details on that. It also lists what variables are actually not allowed to be used. Also, they did clearly explain that it gets past that line and outputs the correct x value. It is the line that is trying to do the debug log on the struct itself that is failing.
 

Hello1423

Member
Try show_message(string(struct.variable)) instead, so you're guaranteed a writeable representation.
Adding string() around _current does not seem to change anything.

This has the same issue with hard crashing at "show_message(string(_current))"
GML:
show_message("test 1")
if is_struct(_current){
    show_message("test 2")
    show_message(_current.x)
    show_message("test 3")
    show_message(string(_current))
    show_message("test 4")
}
 

Hello1423

Member
Actually, it looks like the root issue is some bug with string()

Code:
show_message("test 1")
if is_struct(_current){
    show_message("test 2")
    show_message(_current.x)
    show_message("test 3")
    string(_current)
    show_message("test 4")
}
Even just having string(_current) alone there causes a hard crash.
 

FrostyCat

Redemption Seeker
If _current is self-recursive or contains something else that is, then the process of turning it into a string is infinite and would crash the runner.

If you have no idea what's in it, the safer thing to do is to view it in the debugger. When dealing with nested structures, string uses eager evaluation while the debugger uses lazy evaluation.
 

Hello1423

Member
If _current is self-recursive or contains something else that is, then the process of turning it into a string is infinite and would crash the runner.
Thank you for bringing this up! By working through the debugger I have figured out what must be self recursive within the struct. It makes sense why this can't be simply made into a string.
 
Top