I've managed to crash lwjgl on a consistent basis with the following code:
IntBuffer ibuf = BufferUtils.createIntBuffer(1);
ilGenImages(ibuf);
it crashes the jvm w/ the following error:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=3192, tid=2372
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_04-b05 mixed mode, sharing)
# Problematic frame:
# C 0x00000000
#
# An error report file with more information is saved as hs_err_pid3192.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
the log file that it refers to contains:
Current thread (0x00036b78): JavaThread "main" [_thread_in_native, id=2372]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers:
EAX=0x0b453000, EBX=0x26b060d8, ECX=0x00000000, EDX=0x00000001
ESP=0x0007f9cc, EBP=0x0007fa0c, ESI=0x26b060d8, EDI=0x00036b78
EIP=0x00000000, EFLAGS=0x00010206
Top of Stack: (sp=0x0007f9cc)
0x0007f9cc: 0b701a4a 00000001 0b453000 00ad826f
0x0007f9dc: 00036c34 0007fa14 00000001 0007fa20
0x0007f9ec: 00000000 0007f9f0 26b060d8 0007fa24
0x0007f9fc: 26b08a58 00000000 26b060d8 0007fa1c
0x0007fa0c: 0007fa44 00ad2923 26b08a00 00ad6449
0x0007fa1c: 00000000 22a8ee18 00000001 0007fa28
0x0007fa2c: 26b06055 0007fa4c 26b08a58 00000000
0x0007fa3c: 26b06070 0007fa4c 0007fa6c 00ad2923
Instructions: (pc=0x00000000)
0xfffffff0:
Stack: [0x00040000,0x00080000), sp=0x0007f9cc, free space=254k
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.devil.IL.nilGenImages(ILjava/nio/IntBuffer;I)V+0
j org.lwjgl.devil.IL.ilGenImages(Ljava/nio/IntBuffer;)V+13
j TextureManager.loadTexture(Ljava/lang/String;IIZ)V+75
j CurryChallenge.init()V+118
j CurryChallenge.main([Ljava/lang/String;)V+9
v ~StubRoutines::call_stub
now granted i just found that this is because my code to call IL.create() wasn't getting called, it still seems like a bug to just let the JVM crash
well, we could add a check to all methods that checks if IL has been loaded, and slow all method calls down instead?
It's a simple case of c method pointed pointing to NULL, and nothing we can easily fix without adding lots of code, and/or take a performance hit.
Or simply do it like in OAL. Load java native stubs explicitly on IL.create() (or whatever is relevant). No performance hit, and guards against any use before init.
- elias