This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: segfault in sysdep/i386/backtrace.h


Marco Trudel wrote:
Marco Trudel wrote:
Andrew Haley wrote:
Marco Trudel writes:
> > > The segfault happens on reading scan_bytes[x]. I assume that there is no > "pushl %ebp; movl %esp, %ebp" function prologue in certain cases and > thus we go reading protected areas below the function.


Why don't you have a look, and tell us what is there?

Because I don't know how and what these hex values mean (how to interpret them) when doing the backtrace...

Ok, learnt it...
The problem is that the code assumes that there is always a "pushl %ebp; movl %esp, %ebp" function prologue. But, from [1]: "Note that many compilers can optimize these standard sequences away when not needed (often called "no stackframe generation")".


So, when turning on maximum optimization in microsoft visual c++, there are no longer "pushl %ebp; movl %esp, %ebp" intros and thus we run into trouble (tried it). I don't know if GCC can do that too... Can it?
I checked a couple of dll's (awt.dll, swt.dll, aBluetoothLib.dll) I had around and they all miss the intro in at least a couple of functions.

If someone is interested:


JNIEXPORT void JNICALL Java_JniTest_fooBar(JNIEnv *env, jclass c)
{
	  printf("hello\n");
}

Turns, with mvc no optimization, into:

10001039:	55                   	push   %ebp
1000103a:	8b ec                	mov    %esp,%ebp
1000103c:	68 60 70 00 10       	push   $0x10007060
10001041:	e8 07 00 00 00       	call   0x1000104d
10001046:	83 c4 04             	add    $0x4,%esp
10001049:	5d                   	pop    %ebp
1000104a:	c2 08 00             	ret    $0x8

And, with mvc with optimiation, into:

10001030:	68 60 70 00 10       	push   $0x10007060
10001035:	e8 06 00 00 00       	call   0x10001040
1000103a:	59                   	pop    %ecx
1000103b:	c2 08 00             	ret    $0x8


Marco




So, questions:
- Is this a sjlj-exception only problem? Can DW EH do that better?
- Is there another way to reliably recognize the start of a function? I assume this only affects native libs since Java compiled apps will always have the intro?!



Marco


[1] http://en.wikipedia.org/wiki/X86_calling_conventions#Standard_Exit_and_Entry_Sequences_for_C_Code




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]