Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Bug Report (https://forums.graalonline.com/forums/forumdisplay.php?f=193)
-   -   clearemptyvars() crashes npc server. (https://forums.graalonline.com/forums/showthread.php?t=134259158)

adam 05-13-2010 10:25 PM

clearemptyvars() crashes npc server.
 
PHP Code:

function onCreated() {
  
clearemptyvars(); // doesn't crash when used here
  
  
this.test.var = "testing";
  echo( 
this.test.getDynamicVarNames() );
  
  
this.test.var = "";
  echo( 
this.test.getDynamicVarNames() );
  
  
//clearemptyvars();    // crash's when i swap it to here
  
echo( this.test.getDynamicVarNames() );
  


I'm not exactly sure what's going on here. It seems to crash when used alongside echo() Which is silly.

cbk1994 05-13-2010 10:37 PM

Just tested it and it crashed instantly when uncommenting the line you specified. Strange.

xAndrewx 05-13-2010 10:38 PM

Weird, version 5 right?

Shouldn't it be

HTML Code:

obj.clearemptyvars();
either way, strange how it didn't crash on the first instance

salesman 05-13-2010 10:39 PM

Quote:

Originally Posted by adam (Post 1575868)
PHP Code:

function onCreated() {
  
clearemptyvars(); // doesn't crash when used here
  
  
this.test.var = "testing";
  echo( 
this.test.getDynamicVarNames() );
  
  
this.test.var = "";
  echo( 
this.test.getDynamicVarNames() );
  
  
//clearemptyvars();    // crash's when i swap it to here
  
echo( this.test.getDynamicVarNames() );
  


I'm not exactly sure what's going on here. It seems to crash when used alongside echo() Which is silly.

I can confirm that this crashes the NPC Server, however, it has nothing to do with the echo(). Try setting temp.somevar = this.test.getDynamicVarNames() instead of echoing it, and the server will still crash.

coreys 05-13-2010 10:41 PM

Quote:

Originally Posted by salesman (Post 1575880)
I can confirm that this crashes the NPC Server, however, it has nothing to do with the echo(). Try setting temp.somevar = this.test.getDynamicVarNames() instead of echoing it, and the server will still crash.

It might be some issue in the engine with threading? Race conditions can be nasty. Might be that you're trying to access this.test while it's locked. Though, why that would be done on a separate thread would be beyond me.

adam 05-13-2010 10:46 PM

PHP Code:

function onCreated() {
  
temp.output = {};
  
  
this.test.var = "testing";
  
temp.output.addthis.test.getDynamicVarNames() );
  
  
this.test.var = "";
  
temp.output.addthis.test.getDynamicVarNames() );
  
  
clearemptyvars(); 
  
temp.output.addthis.test.getDynamicVarNames() );
  echo(
temp.output);


This example does not crash. And it also demonstrates the use of clearemptyvars() I was trying to demonstrate. Very useful.

cbk1994 05-13-2010 10:53 PM

Quote:

Originally Posted by xAndrewx (Post 1575879)
Weird, version 5 right?

The NPC-server, not the client ^^.

adam 05-13-2010 11:04 PM

I've actually never used this function clientside. So I dunno about that.

xAndrewx 05-13-2010 11:16 PM

Quote:

Originally Posted by cbk1994 (Post 1575896)
The NPC-server, not the client ^^.

Oh duh, *peeks at thread*


My guess is that it's being used on a global level.

WhiteDragon 05-13-2010 11:55 PM

Well, my original speculation was that this.test was pointing to a memory address which didn't get cleaned up properly when you did clearemptyvars(), so accessing it would cause a seg fault.

But the fact that you can call getdynamicvars and add it to an array but not echo it seems a bit weird...


Maybe it has to do with casting the response of getdynamicvars to a string?

Inverness 05-14-2010 01:25 AM

Graal uses threading for scripts? News to me.


All times are GMT +2. The time now is 10:43 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.