Kernel Panic after exit CudaSetDevice from Java Kernel Panic, Java, CudaSetDevice

Hi

I run a small java program to call cufft and libcuda from Java. The program, looking
for a GPU, setting the device, doing a transfer to device, fft transform, transfer back
is running fine.

The same program runs ok under Java when I also add some swing/awt windows. However
when I exit the program generates a kernel panic (need to reboot machine).
The trace of the panic is attached below.

I reduced the program to just looking for the GPU and calling CudaSetDevice.
The program runs, pops up the proper windows. When exit it panics.

I guess, since the driver/cuda on MacOSX is still in beta, this is what I need to live with.
Just to let you guys know.

Regards
Mark Donszelmann


Mon Apr 21 10:11:50 2008
panic(cpu 1 caller 0x001A8C8A): Kernel trap at 0x00b2c6b3, type 14=page fault, registers:
CR0: 0x8001003b, CR2: 0x0000000c, CR3: 0x013dd000, CR4: 0x00000660
EAX: 0x0725b880, EBX: 0x00000000, ECX: 0x00000001, EDX: 0x0762cce8
CR2: 0x0000000c, EBP: 0x5b09f978, ESI: 0xc1d00054, EDI: 0x00000000
EFL: 0x00010202, EIP: 0x00b2c6b3, CS: 0x00000008, DS: 0x5c000010
Error code: 0x00000000

Backtrace, Format - Frame : Return Address (4 potential args on stack)
0x5b09f778 : 0x12b0f7 (0x4581f4 0x5b09f7ac 0x133230 0x0)
0x5b09f7c8 : 0x1a8c8a (0x461720 0xb2c6b3 0xe 0x460ed0)
0x5b09f8a8 : 0x19ece5 (0x5b09f8c0 0x5b09fa74 0x5b09f978 0xb2c6b3)
0x5b09f8b8 : 0xb2c6b3 (0xe 0x48 0x10 0xb30010)
0x5b09f978 : 0xb3cbef (0x0 0x762cce8 0x0 0x5b09f99c)
0x5b09f9a8 : 0xb86434 (0x7612004 0x0 0x4c908000 0x4c908000)
0x5b09fa38 : 0xb37173 (0xc1d00054 0x5c000001 0x5c000018 0x4c908000)
0x5b09fa98 : 0xb421fa (0xc1d00054 0x5c000001 0x5c000018 0x5c000018)
0x5b09fb08 : 0xb462d9 (0xc1d00054 0x5c000001 0x40 0x5c000018)
0x5b09fb88 : 0xb464a2 (0xc1d00054 0x5c000001 0x0 0x120fcb)
0x5b09fbd8 : 0xb4a89b (0xc1d00054 0x5b09fc2c 0x5b09fc08 0x3ea7d9)
0x5b09fc48 : 0xb2e2b0 (0xc1d00054 0x0 0xc1d00054 0xb2c203)
0x5b09fc68 : 0xb2e326 (0x9a71300 0x9a71300 0x5b09fc98 0xb2bcd8)
0x5b09fc78 : 0xb2bcd8 (0x9a71300 0x10f0 0x5b09fcb8 0x1d)
0x5b09fc98 : 0x43d4ed (0x9a71300 0x5328b0 0x5b09fce8 0x0)
0x5b09fcb8 : 0x187332 (0x9a71300 0x9c1c9d8 0x1d 0x5b09fce8)
Backtrace continues…
Kernel loadable modules in backtrace (with dependencies):
com.apple.NVDAResman(5.2.4)@0xb28000->0xd67fff
dependency: com.apple.iokit.IONDRVSupport(1.5)@0xb1a000
dependency: com.apple.iokit.IOPCIFamily(2.4.1)@0x5c1000
dependency: com.apple.iokit.IOGraphicsFamily(1.5.1)@0xafe000

BSD process name corresponding to current thread: java

Mac OS version:
9C7010

Kernel version:
Darwin Kernel Version 9.2.2: Tue Mar 4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386
System model name: MacBookPro3,1 (Mac-F4238BC8)

Could you please attach the simple version of your code together with the build instructions?

Sure, though the JNI part (generated by SWIG) is not that simple…

I will have a look, and send you details tomorrow.

Regards

Mark Donszelmann

Hi

below the files to build (build.sh) and to run the example that creates the panic.

TestCudaSelect.sh is a non-gui program. It will run normally.
TestCudaSelectGUI.sh pops up a window. It will run. When you exit it from the menu (or ctrl-c)
it will generate a kernel panic, trace in panic-report.txt.

While creating the examples I noticed that the kernel panic is related to:

  1. -Xmx1024M on the command line to start java. Take it away and it will run w/o panic.
  2. GUI. The non gui version also has -Xmx1024M and runs fine.

It is some combination of the two, however we need the memory and the GPU, so we are stuck for
the moment.

Hope you can help me…

Regards
Mark Donszelmann

p.s. The attachment upload did not seem to work, so all files included together:
– build.sh
– TestCudaSelect.sh
– TestCudaSelectGUI.sh
– Cuda.java
– CudaDeviceProp.java
– CudaError.java
– CudaMemcpyKind.java
– CUresult.java
– CudaJNI.java
– cuda_wrap.c
– TestCudaSelect.java
– TestCudaSelectGUI.java
AllFiles.txt (61.1 KB)

The TestCudaSelectGUI.java is missing from your attachment ( it seems like you included TestCudaSelect.java twice).
Can you try to attach a zip file?

And the missing TestCudaSelectGUI.java

import javax.swing.*;

public class TestCudaSelectGUI extends JPanel {

private static void cuCheckError(CUresult error) {

	if (error != CUresult.CUDA_SUCCESS) {

		throw new RuntimeException("Java Cu Exception: " + error.toString());

	}

}

private static void cudaCheckErrorNoSynch(CudaError error) {

	if (error != CudaError.cudaSuccess) {

		throw new RuntimeException("Java Cuda Exception: "

				+ error.toString());

	}

}

private static void cudaCheckError(CudaError error) {

	cudaCheckErrorNoSynch(error);

	error = Cuda.cudaThreadSynchronize();

	if (error != CudaError.cudaSuccess) {

		throw new RuntimeException("Java Cuda Synch Exception: "

				+ error.toString());

	}

}

boolean useGPU;

public TestCudaSelectGUI() {

	useGPU = false;

	int[] deviceCount = new int[1];

	cudaCheckErrorNoSynch(Cuda.cudaGetDeviceCount(deviceCount));

	if (deviceCount[0] > 0) {

		int dev = 0;

		while(dev < deviceCount[0]) {

			CudaDeviceProp deviceProp = new CudaDeviceProp();

			cudaCheckErrorNoSynch(Cuda.cudaGetDeviceProperties(deviceProp,

					dev));

			if (deviceProp.getMajor() >= 1) {

				System.err.println(deviceProp.toString());

				break;

			}

			dev++;

		}

		if (dev != deviceCount[0]) {

			cudaCheckError(Cuda.cudaSetDevice(dev));

			useGPU = true;

		}

	}

}



public static void main(String[] args) {

	TestCudaSelectGUI panel = new TestCudaSelectGUI();

	JFrame f = new JFrame();

	f.setContentPane(panel);

	f.setSize(1200, 400);

	f.setVisible(true);

}

}

I reproduced the crash and will open a bug.
Thanks for reporting it.

Hi

great. That is, that you reproduced the crash.

Is there anywhere we (the community) can follow what happens

to this bug. If not, we just wait the next Beta I guess.

Regards

Mark Donszelmann