[MLton] Crashes with 64-bit native code generator on Windows

David Hansel hansel at reactive-systems.com
Mon Nov 30 09:45:15 PST 2009


Hi Matthew,

Matthew Fluet wrote:
> [...]
> Sounds like a bug in the amd64 codegen simplifier and/or register
> allocator.  It seems that somewhere along the line, the definition of
> the applyFFTempFun variable is being dropped, but the use in the
> indirect call is being retained.  When the register allocator comes
> along, when it doesn't locally find the def point of applyFFTempFun, it
> has to fetch the value from the (uninitialized) variable.
> 
> Could you compile with "-native-commented 3 -native-split 0 -keep g" and
> post the basic block that has the call through applyFFTempFun?  It will
> be pretty noisy, but should shed some light on what the native codegen
> is doing (wrong).

See the code below.  It should match up with the code I posted before.
>From what I can tell it does look like MLton puts the target address for
applyFFTempFun into a register but then later does the indirect call via
the memory location.

Please let me know if you need any more context or other debugging
information.  It does seem like you are on the right track.

Thanks!

David


/* Live: (SW64(24): ExnStack, SW32(40): Word32, SP(64): Objptr (opt_1516), SP(48): Objptr (opt_36)) */
/* begin: RP(0): Objptr (opt_22)  = OP (SP(64): Objptr (opt_1516), 0): Objptr (opt_22) */
/* end: RP(0): Objptr (opt_22)  = OP (SP(64): Objptr (opt_1516), 0): Objptr (opt_22) */
/* begin: RQ(0): CPointer  = OQ (RP(0): Objptr (opt_22), 0): CPointer */
/* end: RQ(0): CPointer  = OQ (RP(0): Objptr (opt_22), 0): CPointer */
/* CCall {args = (RQ(0): CPointer, NULL, 0x0, NULL, SW32(40): Word32), frameInfo = Some {frameLayoutsIndex = 1072}, func = {args = (CPointer, CPointer, Word32, CPointer, Word32), bytesNeeded = None, convention = cdecl, ensuresBytesFree = false, mayGC = true, maySwitchThreads = false, modifiesFrontier = true, prototype = {args = (CPointer, Int32, CPointer, Int32), res = Some Int32}, readsStackTop = true, return = Word32, symbolScope = external, target = <*>, writesStackTop = true}, return = Some L_176133} */
/* begin ccall: cdecl <*> */
/* CCALL cdecl <*>(MEM<q>{Heap}[(MEM<q>{Heap}[(MEM<q>{Stack}[(MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)])+(0x40)])+(0x0)])+(0x0)], $0x0, $0x0, $0x0, MEM<l>{Stack}[(MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)])+(0x28)]) <Some _L_176133> */
/* ************************************************************ */
/* Cache: caches: MEM<q>{StaticNonTemp}[(_c_stackP)+(0x0)] -> %rsp (reserved)  */
	movq (_c_stackP+0x0)(%rip),%rsp
/* ************************************************************ */
/* movq MEM<q>{Heap}[(MEM<q>{Heap}[(MEM<q>{Stack}[(MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)])+(0x40)])+(0x0)])+(0x0)],MEM<q>{CArg}[(_applyFFTempFun)+(0x0)] */
	movq 0x40(%rbp),%r14
	movq 0x0(%r14),%r13
	movq 0x0(%r13),%r11
/* ************************************************************ */
/* movzlq MEM<l>{Stack}[(MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)])+(0x28)],MEM<q>{CArg}[(_applyFFTempRegArg)+(0x0)] */
	movl %r15d,%r9d
/* ************************************************************ */
/* Cache: caches: MEM<q>{CArg}[(_applyFFTempRegArg)+(0x0)] -> %r9 (reserved)  */
/* ************************************************************ */
/* movq $0x0,MEM<q>{CArg}[(_applyFFTempRegArg)+(0x8)] */
	xorq %r8,%r8
/* ************************************************************ */
/* Cache: caches: MEM<q>{CArg}[(_applyFFTempRegArg)+(0x8)] -> %r8 (reserved)  */
/* ************************************************************ */
/* movzlq $0x0,MEM<q>{CArg}[(_applyFFTempRegArg)+(0x10)] */
	movl $0x0,%r15d
	movl %r15d,%edx
/* ************************************************************ */
/* Cache: caches: MEM<q>{CArg}[(_applyFFTempRegArg)+(0x10)] -> %rdx (reserved)  */
/* ************************************************************ */
/* movq $0x0,MEM<q>{CArg}[(_applyFFTempRegArg)+(0x18)] */
	xorq %rcx,%rcx
/* ************************************************************ */
/* Cache: caches: MEM<q>{CArg}[(_applyFFTempRegArg)+(0x18)] -> %rcx (reserved)  */
/* ************************************************************ */
/* subq $0x20,MEM<q>{StaticNonTemp}[(_c_stackP)+(0x0)] */
	subq $0x20,%rsp
/* ************************************************************ */
/* Force: commit_memlocs: commit_classes: remove_memlocs: remove_classes: dead_memlocs: dead_classes:  */
/* ************************************************************ */
/* addq $0x40,MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)] */
	addq $0x40,%rbp
/* ************************************************************ */
/* leaq MEM<q>{Code}[(_L_176133)+(0x0)],MEM<q>{Stack}[(MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)])+(0xFFFFFFFFFFFFFFF8)] */
	leaq (_L_176133+0x0)(%rip),%r15
	movq %r15,0xFFFFFFFFFFFFFFF8(%rbp)
	movq %rbp,(_gcState+0x10)(%rip)
/* ************************************************************ */
/* Force: commit_memlocs: MEM<q>{Stack}[(MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)])+(0xFFFFFFFFFFFFFFF8)] commit_classes: remove_memlocs: remove_classes: dead_memlocs: dead_classes:  */
/* ************************************************************ */
/* Force: commit_memlocs: commit_classes: GCStateVolatile GCState CStatic Globals Stack Heap Code CStack remove_memlocs: remove_classes: dead_memlocs: dead_classes:  */
/* ************************************************************ */
/* Force: commit_memlocs: commit_classes: GCStateVolatile GCStateHold GCState Globals Stack Heap remove_memlocs: remove_classes: dead_memlocs: dead_classes:  */
	movq %r12,(_gcState+0x0)(%rip)
/* ************************************************************ */
/* CCall */
/* ************************************************************ */
/* call *MEM<q>{CArg}[(_applyFFTempFun)+(0x0)] */
	call *(_applyFFTempFun+0x0)(%rip)
/* ************************************************************ */
/* XmmUnreserve: registers:  */
/* ************************************************************ */
/* Unreserve: registers: %rcx %rdx %r8 %r9  */
/* ************************************************************ */
/* Force: commit_memlocs: commit_classes: remove_memlocs: remove_classes: dead_memlocs: dead_classes: GCStateVolatile GCStateHold GCState Globals Stack Heap  */
/* ************************************************************ */
/* Return: [(%eax,MEM<l>{StaticTemp}[(_cReturnTemp)+(0x0)])] */
/* ************************************************************ */
/* addq $0x20,MEM<q>{StaticNonTemp}[(_c_stackP)+(0x0)] */
	addq $0x20,%rsp
/* ************************************************************ */
/* Unreserve: registers: %rsp  */
/* ************************************************************ */
/* Cache: caches: MEM<q>{GCStateHold}[((_gcState+0x0))+(0x0)] -> %r12 (reserved) MEM<q>{GCStateHold}[((_gcState+0x10))+(0x0)] -> %rbp (reserved)  */
	movq (_gcState+0x0)(%rip),%r12
	movq (_gcState+0x10)(%rip),%rbp
/* ************************************************************ */
/* XmmCache: caches:  */
/* ************************************************************ */
/* Cache: caches: MEM<l>{StaticTemp}[(_cReturnTemp)+(0x0)] -> %eax (reserved)  */
/* ************************************************************ */
/* Force: commit_memlocs: commit_classes: GCStateVolatile GCState CStatic Globals Stack Heap Code CStack remove_memlocs: remove_classes: dead_memlocs: dead_classes:  */
/* ************************************************************ */
/* jmp _L_176133 */
	jmp _L_176133




More information about the MLton mailing list