Java error I'm getting in extension

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Kicksome
Posts: 52
Joined: 01 Sep 2007, 02:25
Contact:

Java error I'm getting in extension

Postby Kicksome » 21 Dec 2007, 20:33

I get this error every once in a while. I know it's not directly a smartfox error - it's probably something I'm doing in my code - but if you have any suggestions on where to look for more answers please let me know. I'm tried all Google searches I can think of.

I'm using a zone extension in AS and creating game rooms from there. I pass a ConcurrentHashMap() using
room.properties.put("eihm", eihm) in the zone
and getting it with
eihm = parentmap.properties.get("eihm") in the room
I make changes (in several different rooms) to the hash map - and it updates the zone hashmap.

All that works fine - but it's just crashing every once in a while. Sort of randomly. with about 100 people it might crash after 5 hours or 1 hour.

I'm also passing actionscript objects the same way as I do the hash map- but they are just used to read only - never modified. (lookup tables basically)

Also - in the zone and each room I create I'm doing a:
dbase = _server.getDatabaseManager()

I could have 100 game rooms open at the most.

This error crashes the java.exe and smartfox (although it does restart right away)

#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d8fe2d1, pid=5468, tid=5480
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode)
# Problematic frame:
# V [jvm.dll+0x13e2d1]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

--------------- T H R E A D ---------------

Current thread (0x5332e400): JavaThread "ExtensionHandler-2" daemon [_thread_in_vm, id=5480]

siginfo: ExceptionCode=0xc0000005, reading address 0x00038005

Registers:
EAX=0x00038001, EBX=0x00000192, ECX=0x52bfde58, EDX=0x43c6ed60
ESP=0x538fe4ac, EBP=0x0000036c, ESI=0x55438208, EDI=0x55438208
EIP=0x6d8fe2d1, EFLAGS=0x00010202

Top of Stack: (sp=0x538fe4ac)
0x538fe4ac: 43c6ed60 6d8ff362 55438208 5332e400
0x538fe4bc: 5332e400 55438208 6d92befb 55438208
0x538fe4cc: 5332e400 5544014c 43c6ed60 5332e400
0x538fe4dc: 00902a42 00000000 43c6eac0 00005202
0x538fe4ec: 00000192 5332e400 5332e400 5332e5e8
0x538fe4fc: 6d7c81e0 42691008 5332e400 43c87b78
0x538fe50c: 6d846c04 00000001 7c8279bb 77e62321
0x538fe51c: 00000654 00000000 00000004 6d95f4b2

Instructions: (pc=0x6d8fe2d1)
0x6d8fe2c1: 2b 4d f5 ff 83 c4 14 33 c0 5e c3 8b 16 89 42 3c
0x6d8fe2d1: 8b 48 04 8b 16 89 4a 40 8b 40 04 5e c3 cc cc 56


Stack: [0x538b0000,0x53900000), sp=0x538fe4ac, free space=313k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x13e2d1]

[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j java.lang.Class.getDeclaredConstructors0(Z)[Ljava/lang/reflect/Constructor;+0
j java.lang.Class.privateGetDeclaredConstructors(Z)[Ljava/lang/reflect/Constructor;+87
j java.lang.Class.getConstructor0([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;+10
J java.lang.Class.newInstance0()Ljava/lang/Object;
J java.lang.Class.newInstance()Ljava/lang/Object;
j org.mozilla.javascript.optimizer.Codegen.createScriptObject(Ljava/lang/Object;Ljava/lang/Object;)Lorg/mozilla/javascript/Script;+8
j org.mozilla.javascript.Context.compileImpl(Lorg/mozilla/javascript/Scriptable;Ljava/io/Reader;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;ZLorg/mozilla/javascript/Interpreter;Lorg/mozilla/javascript/ErrorReporter;)Ljava/lang/Object;+339
j org.mozilla.javascript.Context.compileReader(Ljava/io/Reader;Ljava/lang/String;ILjava/lang/Object;)Lorg/mozilla/javascript/Script;+17
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.loadScript()V+211
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.setScriptFile(Ljava/lang/String;)V+17
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.loadExtension(Ljava/lang/String;Ljava/lang/String;I)Lit/gotoandplay/smartfoxserver/extensions/ISmartFoxExtension;+142
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.createExtension(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;IZ)V+13
j it.gotoandplay.smartfoxserver.extensions.ExtensionHelper.createRoom(Lit/gotoandplay/smartfoxserver/data/Zone;Ljava/util/Map;Lit/gotoandplay/smartfoxserver/data/User;Ljava/util/HashMap;Lit/gotoandplay/smartfoxserver/data/User;ZZZ)Lit/gotoandplay/smartfoxserver/data/Room;+716
j sun.reflect.GeneratedMethodAccessor60.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+165
J sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
J java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.MemberBox.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.NativeJavaMethod.call(Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.gen.c1._c18(Lorg/mozilla/javascript/gen/c1;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.gen.c1.call(Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.optimizer.OptRuntime.callN(Lorg/mozilla/javascript/Callable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;)Ljava/lang/Object;
j org.mozilla.javascript.gen.c1._c116(Lorg/mozilla/javascript/gen/c1;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;+1750
J org.mozilla.javascript.gen.c1.call(Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.gen.c1._c114(Lorg/mozilla/javascript/gen/c1;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.gen.c1.call(Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.gen.c1._c52(Lorg/mozilla/javascript/gen/c1;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.gen.c1.call(Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J org.mozilla.javascript.ContextFactory.doTopCall(Lorg/mozilla/javascript/Callable;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
j org.mozilla.javascript.ScriptRuntime.doTopCall(Lorg/mozilla/javascript/Callable;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;+59
J org.mozilla.javascript.gen.c1.call(Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;Lorg/mozilla/javascript/Scriptable;[Ljava/lang/Object;)Ljava/lang/Object;
J it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.handleRequest(Ljava/lang/String;Lit/gotoandplay/smartfoxserver/lib/ActionscriptObject;Lit/gotoandplay/smartfoxserver/data/User;I)V
J it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.processEvent(Lit/gotoandplay/smartfoxserver/lib/ServerEvent;)V
J it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.run()V
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x55508c00 JavaThread "Timer-9392" [_thread_blocked, id=1576]
0x54033400 JavaThread "Timer-9388" daemon [_thread_blocked, id=5696]
0x5439c800 JavaThread "Timer-9387" daemon [_thread_blocked, id=652]
0x555f9400 JavaThread "Timer-9384" daemon [_thread_blocked, id=2612]
0x5416c400 JavaThread "Timer-9383" daemon [_thread_blocked, id=2332]
0x52fdd400 JavaThread "Timer-9382" daemon [_thread_blocked, id=1832]
0x54092000 JavaThread "Timer-9379" daemon [_thread_blocked, id=2496]
0x55515400 JavaThread "Timer-9377" daemon [_thread_blocked, id=6128]
0x55376400 JavaThread "Timer-9375" daemon [_thread_blocked, id=4212]
0x5457c400 JavaThread "Timer-9369" daemon [_thread_blocked, id=1552]
0x533f0400 JavaThread "Timer-9363" daemon [_thread_blocked, id=3708]
0x54a79400 JavaThread "Timer-9361" daemon [_thread_blocked, id=3736]
0x5545c400 JavaThread "Timer-9358" daemon [_thread_blocked, id=760]
0x5457cc00 JavaThread "Timer-9349" daemon [_thread_blocked, id=4824]
0x5315f800 JavaThread "Timer-9331" daemon [_thread_blocked, id=848]
0x55885400 JavaThread "Timer-9321" daemon [_thread_blocked, id=5508]
0x54031800 JavaThread "Timer-9287" daemon [_thread_blocked, id=4520]
0x52f90800 JavaThread "Timer-4" [_thread_blocked, id=5728]
0x52c52800 JavaThread "pool-1-thread-1" [_thread_blocked, id=2512]
0x52beb800 JavaThread "Timer-2" [_thread_blocked, id=3432]
0x52f91800 JavaThread "selector" [_thread_blocked, id=4864]
0x533bfc00 JavaThread "Thread-7" [_thread_blocked, id=2316]
0x53350400 JavaThread "Timer-0" [_thread_blocked, id=5796]
=>0x5332e400 JavaThread "ExtensionHandler-2" daemon [_thread_in_vm, id=5480]
0x5333a400 JavaThread "ExtensionHandler-1" daemon [_thread_in_native, id=3392]
0x53330800 JavaThread "BlueBoxHandler-1" daemon [_thread_blocked, id=2068]
0x532fe400 JavaThread "SystemHandler-1" daemon [_thread_blocked, id=1012]
0x532fdc00 JavaThread "EventWriter-2" daemon [_thread_blocked, id=1240]
0x53280400 JavaThread "EventWriter-1" daemon [_thread_blocked, id=1040]
0x5327f800 JavaThread "SmartFoxServer" [_thread_in_native, id=1788]
0x53267400 JavaThread "H2 TCP Server (tcp://localhost:9009)" [_thread_in_native, id=4356]
0x00297800 JavaThread "DestroyJavaVM" [_thread_blocked, id=4908]
0x53272400 JavaThread "Wrapper-Connection" daemon [_thread_in_native, id=3000]
0x53171800 JavaThread "Wrapper-Control-Event-Monitor" daemon [_thread_blocked, id=4188]
0x52c1d000 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=5504]
0x52c18400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=5616]
0x52c17000 JavaThread "Attach Listener" daemon [_thread_blocked, id=5436]
0x52c16400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=132]
0x52c05000 JavaThread "Finalizer" daemon [_thread_blocked, id=5788]
0x52c04000 JavaThread "Reference Handler" daemon [_thread_blocked, id=5756]

Other Threads:
0x52bff400 VMThread [id=2840]
0x52c27400 WatcherThread [id=3620]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 9216K, used 8457K [0x02690000, 0x03080000, 0x07550000)
eden space 8256K, 92% used [0x02690000, 0x02e05810, 0x02ea0000)
from space 960K, 85% used [0x02f90000, 0x0305cea0, 0x03080000)
to space 960K, 0% used [0x02ea0000, 0x02ea0000, 0x02f90000)
tenured generation total 121024K, used 68285K [0x07550000, 0x0eb80000, 0x42690000)
the space 121024K, 56% used [0x07550000, 0x0b7ff7a8, 0x0b7ff800, 0x0eb80000)
compacting perm gen total 22528K, used 22510K [0x42690000, 0x43c90000, 0x52690000)
the space 22528K, 99% used [0x42690000, 0x43c8bb58, 0x43c8bc00, 0x43c90000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x00423000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\java.exe
0x7c800000 - 0x7c8c0000 C:\WINDOWS\system32\ntdll.dll
0x77e40000 - 0x77f42000 C:\WINDOWS\system32\kernel32.dll
0x77f50000 - 0x77feb000 C:\WINDOWS\system32\ADVAPI32.dll
0x77c50000 - 0x77cef000 C:\WINDOWS\system32\RPCRT4.dll
0x76f50000 - 0x76f63000 C:\WINDOWS\system32\Secur32.dll
0x7c340000 - 0x7c396000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\msvcr71.dll
0x6d7c0000 - 0x6da0a000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\client\jvm.dll
0x77380000 - 0x77411000 C:\WINDOWS\system32\USER32.dll
0x77c00000 - 0x77c48000 C:\WINDOWS\system32\GDI32.dll
0x76aa0000 - 0x76acd000 C:\WINDOWS\system32\WINMM.dll
0x76290000 - 0x762ad000 C:\WINDOWS\system32\IMM32.DLL
0x6d310000 - 0x6d318000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\hpi.dll
0x76b70000 - 0x76b7b000 C:\WINDOWS\system32\PSAPI.DLL
0x6d770000 - 0x6d77c000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\verify.dll
0x6d3b0000 - 0x6d3cf000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\java.dll
0x6d7b0000 - 0x6d7bf000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\zip.dll
0x003e0000 - 0x003f7000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\Server\lib\wrapper.dll
0x6d570000 - 0x6d583000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\net.dll
0x71c00000 - 0x71c17000 C:\WINDOWS\system32\WS2_32.dll
0x77ba0000 - 0x77bfa000 C:\WINDOWS\system32\msvcrt.dll
0x71bf0000 - 0x71bf8000 C:\WINDOWS\system32\WS2HELP.dll
0x71b20000 - 0x71b61000 C:\WINDOWS\system32\mswsock.dll
0x5f270000 - 0x5f2ca000 C:\WINDOWS\system32\hnetcfg.dll
0x71ae0000 - 0x71ae8000 C:\WINDOWS\System32\wshtcpip.dll
0x68000000 - 0x68035000 C:\WINDOWS\system32\rsaenh.dll
0x7c8d0000 - 0x7d0cf000 C:\WINDOWS\system32\SHELL32.dll
0x77da0000 - 0x77df2000 C:\WINDOWS\system32\SHLWAPI.dll
0x77420000 - 0x77523000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_D8713E55\comctl32.dll
0x6d590000 - 0x6d599000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\nio.dll
0x76cf0000 - 0x76d0a000 C:\WINDOWS\system32\iphlpapi.dll
0x76cd0000 - 0x76ce9000 C:\WINDOWS\system32\MPRAPI.dll
0x76df0000 - 0x76e24000 C:\WINDOWS\system32\ACTIVEDS.dll
0x76dc0000 - 0x76de8000 C:\WINDOWS\system32\adsldpc.dll
0x71c40000 - 0x71c97000 C:\WINDOWS\system32\NETAPI32.dll
0x76f10000 - 0x76f3e000 C:\WINDOWS\system32\WLDAP32.dll
0x76b80000 - 0x76bae000 C:\WINDOWS\system32\credui.dll
0x76a80000 - 0x76a98000 C:\WINDOWS\system32\ATL.DLL
0x77670000 - 0x777a9000 C:\WINDOWS\system32\ole32.dll
0x77d00000 - 0x77d8b000 C:\WINDOWS\system32\OLEAUT32.dll
0x76e30000 - 0x76e3c000 C:\WINDOWS\system32\rtutils.dll
0x7e020000 - 0x7e02f000 C:\WINDOWS\system32\SAMLIB.dll
0x770e0000 - 0x771e8000 C:\WINDOWS\system32\SETUPAPI.dll
0x76ed0000 - 0x76efa000 C:\WINDOWS\system32\DNSAPI.dll
0x76f70000 - 0x76f77000 C:\WINDOWS\System32\winrnr.dll
0x76f80000 - 0x76f85000 C:\WINDOWS\system32\rasadhlp.dll
0x6d750000 - 0x6d758000 C:\Program Files\SmartFoxServerPRO_1.6.0_B\jre\bin\sunmscapi.dll
0x761b0000 - 0x76243000 C:\WINDOWS\system32\CRYPT32.dll
0x76190000 - 0x761a2000 C:\WINDOWS\system32\MSASN1.dll

VM Arguments:
jvm_args: -Dfile.encoding=UTF-8 -Djava.util.logging.config.file=logging.properties -XX:MaxPermSize=256m -Xms128m -Xmx1024m -Djava.library.path=lib/ -Dwrapper.key=8cP04aamhx0t9rn5 -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=5016 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=14
java_command: org.tanukisoftware.wrapper.WrapperSimpleApp it.gotoandplay.smartfoxserver.SmartFoxServer
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\PHP\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\Microsoft ADS\bin;C:\Program Files\Microsoft ADS\tools
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 65 Stepping 2, AuthenticAMD



--------------- S Y S T E M ---------------

OS: Windows Server 2003 family Build 3790 Service Pack 2

CPU:total 4 (2 cores per cpu, 1 threads per core) family 15 model 65 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, mmxext, 3dnow, 3dnowext

Memory: 4k page, physical 2097151k(2097151k free), swap 4194303k(4194303k free)

vm_info: Java HotSpot(TM) Client VM (1.6.0_03-b05) for windows-x86, built on Sep 24 2007 22:24:33 by "java_re" with unknown MS VC++:1310
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 Dec 2007, 02:48

Hi Kicksome,

I got the same exact error code as you do. Up until now, I cannot replicate the problem. It happens every 26 hours like I have posted in the forums. You can do a search for 'Exception Access Violation'. If you find a solution, do share it with me :P

I'm not sure where to start from. I've been told to report the crash to Sun but they're silent :lol:

I am doing something close to what you're doing too. I attach properties to my rooms using roomObj.properties.put("propertyname", value) and access them by roomObj.properties.get("propertyname"). Could this be it?

I have a few zone level extensions accessing my database. I had wanted to create one zone level but had to separate them as it was too large and SFS throws an error - "Too complex, more than 5000 lines"? It was something with the same meaning.

Just curious, how do you get your smartfoxserver to restart itself when crash? Is it an in-built feature of SFS that I am not aware of? Or do you have a monitoring tool?
Kicksome
Posts: 52
Joined: 01 Sep 2007, 02:25
Contact:

Postby Kicksome » 22 Dec 2007, 04:12

Yeah - I noticed you had almost the same thing. I actually found it searching on google! lol.

I think the whole point of this error is that it's try to access something that isn't there. So I was thinking something isn't thread safe. Or something is destroyed while we're still trying to access it.

A couple questions:
1) do you us a database?
2) do you use MS sql server JDBC if you do?
3) when you pass objects with the room properties - you're just passing the pointers so you are really reference the object in memory? Which then is really the zone structure.
4) in the rooms you create - are you using at least one Interval?

At first I thought that one of the structures that I was passing wasn't thread safe (I was reading and writing to it) so I made it a thread safe java object - but I get the same error - about the same frequency.

A couple things of note:
1) I do something VERY similar but without using the database directly in SFS. I use loadvars on the server side to load the data in each room. So there is no global access in smartfox. This works great - it NEVER crashes - even with 500 users. The big difference is with the stable version is I do NOT pass any properties to my room. It's created on the client side and uses no database access.
On the unstable version I keep track of everything in SFS Zone memory and broadcast it to players - then create rooms on the server and access the Zone memory data.

2) This leads me to believe it's one of a few things:
a) the database driver or how it's used is just messing things up.
b) maybe the room tries to close before the database access is done- causing problems. (Although I had it setup before so room stuck around for a while and I still had a similar problem)
c) maybe the room tries to close or closes while the room extension is running.
d) maybe some of the global structures we're accessing are just not thread safe (even though we're just reading from them). I might try converting all my actionscript objects that I pass to the room to java thread safe hash tables to see if that makes a difference.
e) maybe we're reading and writing to one of the objects at the same time in the rooms we create.

I'm going to try and mess around with it more. It crashes about every hour or two. And to answer your question - it just automatically restarts - not sure why - but it does.
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 Dec 2007, 04:48

Hi Kicksome,

Seems like your investigations are producing more results than mine. I'll try to answer your questions to my best knowledge as I am not good with terminologies. :lol:

1) Yes I am using Microsoft SQL Server. But I doubt it has to do with this because previously we didn't have our multiplayer battle system inserted and everything ran fine for weeks of no downtime. It started after multiplayer came in.

2) This is the driver setup line on my config.xml - sun.jdbc.odbc.JdbcOdbcDriver

3) If you mean pointers as references, then the answer is no. The room properties are set by the parameters received from players. So I grab it and attach it. I might be wrong as I said my theory is really bad.

Here's how I do it on handleRequest:

Code: Select all

var mapId = params.mapId;
var startedIn = params.startedIn
var status = "wait"
var createdAt = getTimer() / 1000

// Attach from a zone level extension
roomObj.properties.put("mapId", mapId)
roomObj.properties.put("startedIn", startedIn)
roomObj.properties.put("status", status)
roomObj.properties.put("createdAt", createdAt)
roomObj.properties.put("pause", 1)

// Access them from each room extension
var roomObj = _server.getCurrentRoom()
var mapId = roomObj.properties.get("mapId")
var startedIn = roomObj.properties.get("startedIn")
var status = roomObj.properties.get("status")
var createdAt = roomObj.properties.get("createdAt")
var pause = roomObj.properties.get("pause")


So it goes something like that. I don't think there is anything wrong with that?

4) I have 3 intervals running in my whole application. One is to watch for expiry in the game market which is set at a 1hr interval. The other two are used to watch my game rooms. Out of these two, one is running to search for empty game rooms. The search looks for empty game rooms that was created 5 mins ago. I assume this as a timeout.

I'm not sure why but I get these empty rooms now and then. I allow only one room to be created by each encounter of monster in my maps by each player but it sometimes allows them to create more than a room. Might be bad coding on my part.

The third timer is running every second. Each time it is called, it will send a countdown to every game room with users in it, have pause = 0 and if 30 secs countdown for the room have not passed. So you can safely say that if I have 100 rooms registered with my ClockManager, the third interval will send out messages to 100 rooms every second. E.g. room 1 shows 20 secs left, room 2 shows 3 secs left, room 3 shows 30 secs left... and so on. All controlled by the ClockManager. It is something like the new feature in 1.6 Scheduler, but mine isn't as great. We never had more than 20 tasks registered so I don't think we reached the "stress" peak yet?

After all that, I agree with your point on 2c) and 2e). Why? Cos I noticed that my function to search for empty game rooms sometimes destroys a room that got created like 1 sec ago! So it goes like I create a room while waiting for server to send me a response, the room got destroyed and when I finally get the response I join it fails. It happens sometimes though but it could be the cause of it too.

Strangely, even though it happens, the crash comes just about every 26 hours. I hope we can find the source of the problem and hope to learn this. I am a new young programmer still learning the ropes! :P

Thanks,
darnpunk
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 22 Dec 2007, 14:00

What i notice on first sight is that both of you are using the rhyno lib (AS extensions). And both error are occurred when you are creating rooms.

Also the Heap trace show that some areas of the heap are almost full.

Can you confirm that in all error trace you have this

Code: Select all

j it.gotoandplay.smartfoxserver.extensions.ExtensionHelper.createRoom
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 Dec 2007, 14:18

Hi patso,

Yes you are right. There's a similar line in the crash log. Here is from mine:

j it.gotoandplay.smartfoxserver.extensions.ExtensionHelper.createRoom(Lit/gotoandplay/smartfoxserver/data/Zone;Ljava/util/Map;Lit/gotoandplay/smartfoxserver/data/User;Ljava/util/HashMap;Lit/gotoandplay/smartfoxserver/data/User;ZZZ)Lit/gotoandplay/smartfoxserver/data/Room;+668

I hope we're getting nearer to a solution :D

Thanks,
darnpunk
Kicksome
Posts: 52
Joined: 01 Sep 2007, 02:25
Contact:

Postby Kicksome » 22 Dec 2007, 14:52

Yes - I have that line - I checked the last 10 hs_err*.logs. All of the look almost same to the two below:

crashes at [from now going back] ( 9:38am, 8:05am, 6:07am, 3:57am, 2:03am, 12:38am, 11:08pm, 9:42pm, 8:05 pm, 6:29pm)

[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j java.lang.Class.getDeclaredConstructors0(Z)[Ljava/lang/reflect/Constructor;+0
j java.lang.Class.privateGetDeclaredConstructors(Z)[Ljava/lang/reflect/Constructor;+87
j java.lang.Class.getConstructor0([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;+10
J java.lang.Class.newInstance0()Ljava/lang/Object;
J java.lang.Class.newInstance()Ljava/lang/Object;
j org.mozilla.javascript.optimizer.Codegen.createScriptObject(Ljava/lang/Object;Ljava/lang/Object;)Lorg/mozilla/javascript/Script;+8
j org.mozilla.javascript.Context.compileImpl(Lorg/mozilla/javascript/Scriptable;Ljava/io/Reader;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;ZLorg/mozilla/javascript/Interpreter;Lorg/mozilla/javascript/ErrorReporter;)Ljava/lang/Object;+339
j org.mozilla.javascript.Context.compileReader(Ljava/io/Reader;Ljava/lang/String;ILjava/lang/Object;)Lorg/mozilla/javascript/Script;+17
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.loadScript()V+211
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.setScriptFile(Ljava/lang/String;)V+17
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.loadExtension(Ljava/lang/String;Ljava/lang/String;I)Lit/gotoandplay/smartfoxserver/extensions/ISmartFoxExtension;+142
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.createExtension(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;IZ)V+13
j it.gotoandplay.smartfoxserver.extensions.ExtensionHelper.createRoom(Lit/gotoandplay/smartfoxserver/data/Zone;Ljava/util/Map;Lit/gotoandplay/smartfoxserver/data/User;Ljava/util/HashMap;Lit/gotoandplay/smartfoxserver/data/User;ZZZ)Lit/gotoandplay/smartfoxserver/data/Room;+716
j

----
[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j java.lang.Class.getDeclaredConstructors0(Z)[Ljava/lang/reflect/Constructor;+0
j java.lang.Class.privateGetDeclaredConstructors(Z)[Ljava/lang/reflect/Constructor;+87
j java.lang.Class.getConstructor0([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;+10
J java.lang.Class.newInstance0()Ljava/lang/Object;
J java.lang.Class.newInstance()Ljava/lang/Object;
j org.mozilla.javascript.optimizer.Codegen.createScriptObject(Ljava/lang/Object;Ljava/lang/Object;)Lorg/mozilla/javascript/Script;+8
j org.mozilla.javascript.Context.compileImpl(Lorg/mozilla/javascript/Scriptable;Ljava/io/Reader;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;ZLorg/mozilla/javascript/Interpreter;Lorg/mozilla/javascript/ErrorReporter;)Ljava/lang/Object;+339
j org.mozilla.javascript.Context.compileReader(Ljava/io/Reader;Ljava/lang/String;ILjava/lang/Object;)Lorg/mozilla/javascript/Script;+17
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.loadScript()V+211
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.setScriptFile(Ljava/lang/String;)V+17
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.loadExtension(Ljava/lang/String;Ljava/lang/String;I)Lit/gotoandplay/smartfoxserver/extensions/ISmartFoxExtension;+142
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.createExtension(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;IZ)V+13
j it.gotoandplay.smartfoxserver.extensions.ExtensionHelper.createRoom(Lit/gotoandplay/smartfoxserver/data/Zone;Ljava/util/Map;Lit/gotoandplay/smartfoxserver/data/User;Ljava/util/HashMap;Lit/gotoandplay/smartfoxserver/data/User;ZZZ)Lit/gotoandplay/smartfoxserver/data/Room;+716
j

---
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 Dec 2007, 14:58

Hi Kicksome,

Looks like our crash logs are very similar. Here's mine again:

[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j java.lang.Class.getDeclaredConstructors0(Z)[Ljava/lang/reflect/Constructor;+0
j java.lang.Class.privateGetDeclaredConstructors(Z)[Ljava/lang/reflect/Constructor;+87
J java.lang.Class.getConstructor0([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;
j java.lang.Class.newInstance0()Ljava/lang/Object;+32
j java.lang.Class.newInstance()Ljava/lang/Object;+15
j org.mozilla.javascript.optimizer.Codegen.createScriptObject(Ljava/lang/Object;Ljava/lang/Object;)Lorg/mozilla/javascript/Script;+8
j org.mozilla.javascript.Context.compileImpl(Lorg/mozilla/javascript/Scriptable;Ljava/io/Reader;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;ZLorg/mozilla/javascript/Interpreter;Lorg/mozilla/javascript/ErrorReporter;)Ljava/lang/Object;+339
j org.mozilla.javascript.Context.compileReader(Ljava/io/Reader;Ljava/lang/String;ILjava/lang/Object;)Lorg/mozilla/javascript/Script;+17
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.loadScript()V+211
j it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.setScriptFile(Ljava/lang/String;)V+17
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.loadExtension(Ljava/lang/String;Ljava/lang/String;I)Lit/gotoandplay/smartfoxserver/extensions/ISmartFoxExtension;+172
j it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.createExtension(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)V+13
j it.gotoandplay.smartfoxserver.extensions.ExtensionHelper.createRoom(Lit/gotoandplay/smartfoxserver/data/Zone;Ljava/util/Map;Lit/gotoandplay/smartfoxserver/data/User;Ljava/util/HashMap;Lit/gotoandplay/smartfoxserver/data/User;ZZZ)Lit/gotoandplay/smartfoxserver/data/Room;+668
Kicksome
Posts: 52
Joined: 01 Sep 2007, 02:25
Contact:

Postby Kicksome » 22 Dec 2007, 15:03

A couple side notes.
I have the Java settings:
-XX:MaxPermSize=256m -Xms128m -Xmx1024m
the java.exe process is never over 300 megs. So maybe I should make the -Xms1024? Just in case it's having trouble dynamically allocating the memory??? Not sure...

As far as the create room. I'm doing the follow:

Code: Select all

function createcombatroom(encounterid, user, player1, player2) {

   var t_hm = eihm.get(encounterid)
   if ((t_hm == undefined) || t_hm.deletedflag=="Y") {
      //this encounter isn't ready yet send a response to the player to abort
      trace("Battle is over already: " + encounterid)
      var t = []
      t.push("nobattle")
      _server.sendResponse(t, -1, null, [user], "str")
      trace("sending nobattle to "  + user.getName());
      return 1
   }
   
   if (zone.getRoomByName("C"+encounterid) == undefined) {
      var roomObj = {}
      roomObj.name = "C"+encounterid
      roomObj.maxU = 5
      roomObj.isGame = true
      
      //pvp if over 50000
      if (Number(encounterid) >= 50000) {
         roomObj.xtClass = "/GOT/pvp.as"
         var roomVars =    [
               {name:"parentroomid", val:mainroomid, priv:true, persistent:true},
               {name:"encounterid", val:encounterid, priv:true, persistent:true},
               {name:"player1", val:player1, priv:true, persistent:true},
               {name:"player2", val:player2, priv:true, persistent:true},
            ]               
      } else {
         //this is a normal combatroom
         roomObj.xtClass = "/GOT/combat.as"   
            var roomVars =    [
               {name:"parentroomid", val:mainroomid, priv:true, persistent:true},
               {name:"encounterid", val:encounterid, priv:true, persistent:true},
               {name:"mobid1", val:t_hm.mobid1, priv:true, persistent:true},
               {name:"mobid2", val:t_hm.mobid2, priv:true, persistent:true},
               {name:"mobid3", val:t_hm.mobid3, priv:true, persistent:true},
               {name:"npclevel1", val:t_hm.npclevel1, priv:true, persistent:true},
               {name:"npclevel2", val:t_hm.npclevel2, priv:true, persistent:true},
               {name:"npclevel3", val:t_hm.npclevel3, priv:true, persistent:true},
            ]         
         
         
      }
      roomObj.xtName = roomObj.name
      var newRoom = _server.createRoom(roomObj, user, false, false, roomVars)
      if (newRoom != null) {
         //good to go
      } else {
         trace("A problem occurred, better check the server logs")
         trace("Room not created - problem eid: " + encounterid)
         var t = []
         t.push("nobattle")
         _server.sendResponse(t, -1, null, [user], "str")
         trace("sending nobattle to "  + user.getName());
         return 1
      }
         

      var newId = newRoom.getId()
      if (user != null) {
         var ok = _server.joinRoom(user, currentRoomId, true, newId)
         if (ok) {
            //trace("Success!")
         }
      }
   } else {
      //trace("room already exists")
      var joinroom = zone.getRoomByName("C"+encounterid)
      var joinid = joinroom.getId()
      if (user != null) {
         var ok = _server.joinRoom(user, currentRoomId, true, joinid)
      }
   }
}



and in my init for the room I'm doing:


Code: Select all

function init()
{
   // Using trace will send data to the server console
   zone = _server.getCurrentZone()
   room = _server.getCurrentRoom()
   trace("Extension is running in zone: " + zone.getName() + " id:" + room.getId())
   dbase = _server.getDatabaseManager()
}




Then I have an init1() when the first player joins the room since for some reason I can't run this in init

Code: Select all

function init1(){
   if (startup != 0)
      return;
   /* this whole piece just gets handle of the parent id combat room */
   var rVars = room.getVariables()

   // We cycle through the HashMap and trace each variable
   for (var i = rVars.entrySet().iterator(); i.hasNext();)
   {
      var rVar = i.next()
      var varName = rVar.getKey()
      var varValue = rVar.getValue().getValue()
      
      if (varName == "parentroomid") {
         roomid = varValue
      }
      
      if (varName == "encounterid") {
         rid = Number(varValue)
      }
      
      if (varName == "mobid1") {
         var mobid1 = Number(varValue)
      }
        
      if (varName == "mobid2") {
         var mobid2 = Number(varValue)
      }
            
      if (varName == "mobid3") {
         var mobid3 = Number(varValue)
      }

      if (varName == "npclevel1") {
         var npclevel1 = Number(varValue)
      }

      if (varName == "npclevel2") {
         var npclevel2 = Number(varValue)
      }
      
      if (varName == "npclevel3") {
         var npclevel3 = Number(varValue)
      }
      
      trace("var: " + varName + ", val: " + varValue)
   }

   var parentmap = zone.getRoom(roomid)
   
   //get the pointers to the global data structs from the parent room
   npc = parentmap.properties.get("npc")
   eihm = parentmap.properties.get("eihm")
   refexplevel = parentmap.properties.get("refexplevel")
   refitemtype = parentmap.properties.get("refitemtype")
   mapbackgrounds = parentmap.properties.get("mapbackgrounds")   
   
   //now create the encounter...
   var t_hm = eihm.get(rid)
   makeencounter(rid, t_hm.x,t_hm.y, mobid1, t_hm.mapid)
   startup = 1

}

[/code]
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 Dec 2007, 15:08

Hi Kicksome,

I just took a brief look at your codes and I am doing really similar to yours. For the init1() part, I am also not able to init some variables when the extension is loaded into the room somehow in the default function init(). I wait for a player to join in before I assign the monsters to the room too. Maybe we need to change the design for the code logic? I am not too sure.

I already allocated more memory to the game earlier today and I am waiting to see if it will crash when the server uptime reaches approx 26 hours come tomorrow :cry:

Regards,
darnpunk
Kicksome
Posts: 52
Joined: 01 Sep 2007, 02:25
Contact:

Postby Kicksome » 22 Dec 2007, 15:20

I just happened to crash - so it's using the new 1 gig min settings. Although it's not showing the max memory as 1gig in use for java. It looks the same as far as memory allocation. Not sure why it's just not allocating 1 gig at the start as I set that for min memory.

Since today is a very popular day - it looks like it's crashing more frequently.

Now - the other SFS instance has been up for over 2 days with 400+ players online right now. (same machine) It's using about 400 gigs memory.

The one I'm testing is running with about 70 - 80 users right now. (this is the one that crashes)
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 Dec 2007, 15:36

That's kind of odd. Usually, those with more users should be the one to face a crash instead isn't it? :P Anyway, I do not think it's insufficient memory. Correct me if I am wrong. I used to have a OutOfMemory error but that never happened again after I optimized some of the scripts. Then later on, this error starts to happen.

Btw, the other stable SFS instance you're running with 400+ players online, do they have rooms created with attached properties just like the one that is crashing?
Kicksome
Posts: 52
Joined: 01 Sep 2007, 02:25
Contact:

Postby Kicksome » 22 Dec 2007, 16:02

With the 400+ player one that's rock solid It creates the room from the flash client. (which I don't like obviously)
There are no room variables or anything. The client passes the fight number and the server loads that info from a loadvars.

The init is really simple for the stable one

Code: Select all

function init()
{
   // Using trace will send data to the server console
   trace("Combat Instance Created!")
   numplayers = 0
   intervalstart = setInterval("startbattle", 3000)   
}



On another note.

I just tried getting room properties and variables from init() and it seems to work for me now. Really strange - it didn't in the last SFS version. Maybe I changed something in how I created the rooms that is letting it work now. Oh wait - I think I know. Before I had the server own the room - now the user owns the room and it's a game room. I guess you can't get room vars if the server owns the room in the init()???

I just changed my code to NOT do the second init1(). I do everything in init now since the user owns the room it works. Also the rooms auto-clean themselves when the user owns them. This works well for me at least.
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 Dec 2007, 16:07

I prefer to create rooms from server side too. I feel it's much more secured and also allows you to change the codes anytime if something goes wrong and just reload it :D

I've started to let the rooms owned by users too but the crash still occurs. I haven't try accessing the vars on init(). Did it help on the crash? I think not, right? In any case, accesing the vars when a user enters the room is much more clean? It doesn't load any vars when there is no need for it. This is my personal opinion. But again, my opinion could be a sin. :P

Do you suspect the crash is greatly linked to the way we create and attach properties to new game rooms?
Kicksome
Posts: 52
Joined: 01 Sep 2007, 02:25
Contact:

Postby Kicksome » 22 Dec 2007, 16:50

Well - I tried accessing everything from the init() and it still crashed. I guess I'll see how long it lasts and if it makes any difference now that it's a fresh restart. As far as accessing the variables from the init.

As far as the room creation... It sure looks like it could be the problem.

My log says:
About to create room: C1105
then it does a few more things because other extensions are processing...
then it crashes...

Normally is says:
About to create room: C1105
few more things from other extensions
[ INFO ] > Room Extension [ C1105 ] created!

I wonder if it could be reusing the same room name - maybe the room vars don't get totally destroyed or something??? I do reuse the same room names. But in this case they get deleted and don't get re-created for at least a minute.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 26 guests