Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Error 111: Crash in Script, causes unknown #451558
05/11/15 17:53
05/11/15 17:53
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
The following simple script leads to generic Error 111: Crash in Script.
Code:
#define MAX_POINTS 2000

typedef struct {
  var a;
  var b;
  int c;
} MYST;

function unused(MYST* mysts) {
  mysts[0].c = 0;
}

function run() {
  StartDate = 20120815;
  EndDate = 20120901;
  var ds[MAX_POINTS];
  var es[MAX_POINTS];
  MYST fs[MAX_POINTS];
}



Strangely, the presence of function "unused" is significant (If I remove it, the script does not crash.) This defies all my debugging fu.

What is going on here?

Last edited by GPEngine; 05/11/15 18:50.
Re: Error 111: Crash in Script, causes unknown [Re: GPEngine] #451559
05/11/15 18:22
05/11/15 18:22
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
A function should not be named "function", or else your code won't compile. But I think you'll also get a stack problem. The stack has limited size and is for local variables - large arrays should be global, or static, or allocated at runtime.

Re: Error 111: Crash in Script, causes unknown [Re: jcl] #451561
05/11/15 18:49
05/11/15 18:49
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
"int function" was a typo. I meant "function unused"

Regarding stack size, this is really painful.

Re: Error 111: Crash in Script, causes unknown [Re: GPEngine] #451566
05/11/15 20:57
05/11/15 20:57
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
This error could be detected using static analysis at compile time.
Short of that, can the error message at least say "Stack Overflow"?

Re: Error 111: Crash in Script, causes unknown [Re: GPEngine] #451576
05/12/15 09:55
05/12/15 09:55
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
In an ideal world, sure, but I know no such intelligent C compiler. Runtime stack checking is supported in debugging mode by some compilers. Normal programs do no stack checking as to my knowledge.

Re: Error 111: Crash in Script, causes unknown [Re: jcl] #451614
05/13/15 05:45
05/13/15 05:45
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
Hope this helps.
Code:
$ cat star.c
#define MAX_POINTS 2000000

void run() {
  double ds[MAX_POINTS];
  ds[0] = 1.;
}

int main() {
  run();
  return 0;
}
$ gcc -c -fstack-usage star.c
$ cat star.su 
star.c:3:6:run	15999896	static
star.c:8:5:main	16	static
$ ./a.out 
Segmentation fault (core dumped)

$ gcc -c -Wstack-usage=10000 star.c
star.c: In function ‘run’:
star.c:6:1: warning: stack usage is 15999896 bytes [-Wstack-usage=]
 }
 ^


Re: Error 111: Crash in Script, causes unknown [Re: GPEngine] #451632
05/14/15 08:34
05/14/15 08:34
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Not really: GCC prints here only the size of local variables. I suppose it is difficult, if not impossible, that a compiler can detect when the stack is exceeded. For this it had to analyze the call depth of functions.

Possible would be some sort of warning when the compiler sees something suspicious in the run function, such as a local array.

Re: Error 111: Crash in Script, causes unknown [Re: jcl] #451676
05/16/15 02:57
05/16/15 02:57
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline OP
User
GPEngine  Offline OP
User
G

Joined: Sep 2013
Posts: 504
California
Right. I'm not asking for perfect anticipation of the stack usage or live monitoring of the stack. I'm just asking for a sanity check regarding local variables, considering that the stack size Zorro allocates is much smaller than what -- pardon the generalization -- application programmers may be used to.

Last edited by GPEngine; 05/16/15 03:55.

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1