[Bug 134] New: Segmentation fault when debugging SableVM with Valgrind
[email protected] Fri, 6 May 2005 17:36:56 -0400
| Newsgroups | gmane.comp.java.vm.sablevm.bugs |
|---|---|
| Message-ID | <[email protected]> |
http://sablevm.org/bugs/show_bug.cgi?id=134
Summary: Segmentation fault when debugging SableVM with Valgrind
Product: SableVM
Version: 1.11[.x]
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: default
AssignedTo: [email protected]
ReportedBy: [email protected]
QAContact: [email protected]
Hi all,
While developping an application, I used some memory debuggers (Valgrind and
Electric Fence) to do some investigation about a weird behaviour. My application
is a Java application (Bridge.java) that launches another application
(Hello.java) via reflection. This happens with versions 1.11.3 and 1.11.3-1 of
SableVM.
The normal output of my program is "Nizar found a bug". When I run Valgrind on
SableVM, I get the following output:
==3904== Memcheck, a memory error detector for x86-linux.
==3904== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==3904== Using valgrind-2.2.0, a program supervision framework for x86-linux.
==3904== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==3904== For more details, rerun with: -v
==3904==
==3904== Thread 2:
==3904== Use of uninitialised value of size 4
==3904== at 0x1B91573D: _svmh_resuming_java (thread.c:1075)
==3904== by 0x1B9A9969: Java_java_lang_VMThread_currentThread
(java_lang_VMThread.c:216)
==3904== by 0x1BB587FA: ffi_call_SYSV (in /usr/lib/libffi.so.2.0.0)
==3904== by 0x1BB58486: ffi_call (in /usr/lib/libffi.so.2.0.0)
==3904==
==3904== Thread 2:
==3904== Invalid read of size 4
==3904== at 0x1B91573D: _svmh_resuming_java (thread.c:1075)
==3904== by 0x1B9A9969: Java_java_lang_VMThread_currentThread
(java_lang_VMThread.c:216)
==3904== by 0x1BB587FA: ffi_call_SYSV (in /usr/lib/libffi.so.2.0.0)
==3904== by 0x1BB58486: ffi_call (in /usr/lib/libffi.so.2.0.0)
==3904== Address 0x8ACC5004 is not stack'd, malloc'd or (recently) free'd
==3904==
==3904== Process terminating with default action of signal 11 (SIGSEGV)
==3904== at 0x1B91573D: _svmh_resuming_java (thread.c:1075)
==3904== by 0x1B9A9969: Java_java_lang_VMThread_currentThread
(java_lang_VMThread.c:216)
==3904== by 0x1BB587FA: ffi_call_SYSV (in /usr/lib/libffi.so.2.0.0)
==3904== by 0x1BB58486: ffi_call (in /usr/lib/libffi.so.2.0.0)
==3904==
==3904== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 33 from 1)
==3904== malloc/free: in use at exit: 20827577 bytes in 8600 blocks.
==3904== malloc/free: 23615 allocs, 15015 frees, 22123764 bytes allocated.
==3904== For a detailed leak analysis, rerun with: --leak-check=yes
==3904== For counts of detected errors, rerun with: -v
/export/nobackup/localhost/nizar/svm/lib/sablevm/bin/java: line 260: 3904
Segmentation fault valgrind $JVM $VER $OPTS $REST $MAIN "$@"
Error: unable to execute /export/nobackup/localhost/nizar/svm/bin/sablevm.
I can force it to dump a core file and its backtrace is:
(gdb) bt
#0 0x1b91573d in _svmh_resuming_java (env=0x0) at thread.c:1075
#1 0x00000000 in ?? ()
This is obtained while compiling sableVM with --enable-debugging-features. The
default compilation returns the same output plus a large amount of other errors
(certainly due to the use of signals). I enclosed my source code to allow you to
reproduce the bug. Compile and run it with:
valgrind sablevm -Y Bridge
Or simply replace the following line in the java wrapper (i.e.
{JAVA-HOME}/bin/java-sablevm):
exec $JVM $VER $OPTS $REST $MAIN "$@"
with:
valgrind $JVM $VER $OPTS $REST $MAIN "$@"
First, I was not sure wether the problem was from Valgrind or SableVM, so i ran
the same example with another JVM and it worked fine. Unfortunately, I do not
have enough time to go further on this bug...
Thanks,
Nizar
/*
***********************
* Bridge.java
***********************
*/
import java.lang.reflect.*;
class Hello2 extends Thread {
private Class mainClass;
private String className;
private Method mainMethod;
private String[] parameters;
private Class[] parameterTypes;
private Object[] parameterList;
public Hello2(String className, String[] parameters) {
this.className = className;
this.parameters = parameters;
this.parameterTypes = new Class[1];
this.parameterList = new Object[1];
this.parameterList[0] = parameters;
}
boolean setup() {
/* get the class whose name has been passed in parameters */
try {
mainClass = Class.forName(this.className);
} catch (Exception e) {
System.out.println("Error: exception thrown during class access!");
return false;
}
/* get the passed parameters type */
this.parameterTypes[0] = this.parameters.getClass();
/* get the main */
try {
mainMethod = mainClass.getMethod("main", parameterTypes);
} catch (Exception e) {
System.out.println("Error: exception thrown during method access!");
return false;
}
return true;
}
public void run() {
/* call the main method */
/* as main is static, one can invoke it from the Class not the instance */
try {
mainMethod.invoke(null, this.parameterList);
} catch (Exception e) {
System.out.println("Error: exception thrown running method !" + e);
System.exit(0);
}
}
}
public class Bridge {
static Hello2 helper;
/* main */
public static void main(String[] args) {
Bridge bridge = new Bridge();
String start;
start = "Hello";
//System.out.println("start " + start);
//System.out.println("JAVA : helper creation");
helper = new Hello2(start, args);
//System.out.println("JAVA : helper setup");
if (helper.setup() == false) {
System.out.println("Error: an error occured during class setup!");
System.exit(0);
}
//System.out.println("JAVA : helper start");
helper.start();
}
}
/*
***********************
* Hello.java
***********************
*/
public class Hello {
public static void main(String[] args) {
System.out.println ("Nizar found a bug");
}
}
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
You are the QA contact for the bug, or are watching the QA contact.