[MLton-devel] strip bug on Debian causing MLton segfault

Stephen Weeks MLton@mlton.org
Tue, 15 Jul 2003 15:58:24 -0700


> You could check some of this by setting a break point in main and then running
> the version.  When it gets to the break point, look at /proc/<pid>/maps
> and see what things look like in the stripped and non-stripped version.

Here is what /proc/<pid>/maps looks like for the unstripped version
(mlton-compile.orig) when it reaches the breakpoint at main.

08048000-08786000 r-xp 00000000 03:02 99701      /tmp/mlton-compile.orig
08786000-08897000 rw-p 0073d000 03:02 99701      /tmp/mlton-compile.orig
08897000-0889f000 rwxp 00000000 00:00 0
40000000-40011000 r-xp 00000000 03:02 162070     /lib/ld-2.3.1.so
40011000-40012000 rw-p 00011000 03:02 162070     /lib/ld-2.3.1.so
4001d000-4003d000 r-xp 00000000 03:02 162248     /lib/libm-2.3.1.so
4003d000-4003e000 rw-p 0001f000 03:02 162248     /lib/libm-2.3.1.so
4003e000-4003f000 rw-p 00000000 00:00 0
4003f000-40147000 r-xp 00000000 03:02 162169     /lib/libc-2.3.1.so
40147000-4014d000 rw-p 00107000 03:02 162169     /lib/libc-2.3.1.so
4014d000-4014f000 rw-p 00000000 00:00 0
bfffe000-c0000000 rwxp fffff000 00:00 0

Here is what it looks like for the stripped version.

08048000-08786000 r-xp 00000000 03:02 99717      /tmp/mlton-compile
08786000-08897000 rw-p 0073d000 03:02 99717      /tmp/mlton-compile
08897000-0889f000 rwxp 00000000 00:00 0
40000000-40011000 r-xp 00000000 03:02 162070     /lib/ld-2.3.1.so
40011000-40012000 rw-p 00011000 03:02 162070     /lib/ld-2.3.1.so
4001d000-4003d000 r-xp 00000000 03:02 162248     /lib/libm-2.3.1.so
4003d000-4003e000 rw-p 0001f000 03:02 162248     /lib/libm-2.3.1.so
4003e000-4003f000 rw-p 00000000 00:00 0
4003f000-40147000 r-xp 00000000 03:02 162169     /lib/libc-2.3.1.so
40147000-4014d000 rw-p 00107000 03:02 162169     /lib/libc-2.3.1.so
4014d000-4014f000 rw-p 00000000 00:00 0
bfffe000-c0000000 rwxp fffff000 00:00 0

They look the same to me.
 
> If the problem is the table of addresses in the stripped executable being
> mangled, you can use the objdump program to see what it looks like.
> The usage is a mess but I remember getting various things dumped out.

Here is objdump -h for both exectubles

mlton-compile.orig:     file format elf32-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .interp       00000013  08048114  08048114  00000114  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .note.ABI-tag 00000020  08048128  08048128  00000128  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .hash         00000264  08048148  08048148  00000148  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .dynsym       00000540  080483ac  080483ac  000003ac  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .dynstr       000002b5  080488ec  080488ec  000008ec  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .gnu.version  000000a8  08048ba2  08048ba2  00000ba2  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .gnu.version_r 00000040  08048c4c  08048c4c  00000c4c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .rel.dyn      00000020  08048c8c  08048c8c  00000c8c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .rel.plt      00000258  08048cac  08048cac  00000cac  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .init         00000017  08048f04  08048f04  00000f04  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 10 .plt          000004c0  08048f1c  08048f1c  00000f1c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 11 .text         0071cd18  080493e0  080493e0  000013e0  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 12 .fini         0000001d  087660f8  087660f8  0071e0f8  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 13 .rodata       0001ef08  08766120  08766120  0071e120  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 14 .eh_frame_hdr 0000001c  08785028  08785028  0073d028  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 .data         00110930  08786060  08786060  0073d060  2**5
                  CONTENTS, ALLOC, LOAD, DATA
 16 .eh_frame     0000005c  08896990  08896990  0084d990  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 .dynamic      000000d0  088969ec  088969ec  0084d9ec  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 18 .ctors        00000008  08896abc  08896abc  0084dabc  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 19 .dtors        00000008  08896ac4  08896ac4  0084dac4  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 20 .jcr          00000004  08896acc  08896acc  0084dacc  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 21 .got          00000140  08896ad0  08896ad0  0084dad0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 22 .bss          0000800c  08896c20  08896c20  0084dc20  2**5
                  ALLOC
 23 .stab         01265244  00000000  00000000  0084dc20  2**2
                  CONTENTS, READONLY, DEBUGGING
 24 .stabstr      0009d688  00000000  00000000  01ab2e64  2**0
                  CONTENTS, READONLY, DEBUGGING
 25 .comment      0000122d  00000000  00000000  01b504ec  2**0
                  CONTENTS, READONLY


mlton-compile:     file format elf32-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .interp       00000013  08048114  08048114  00000114  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .note.ABI-tag 00000020  08048128  08048128  00000128  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .hash         00000264  08048148  08048148  00000148  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .dynsym       00000540  080483ac  080483ac  000003ac  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .dynstr       000002b5  080488ec  080488ec  000008ec  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .gnu.version  000000a8  08048ba2  08048ba2  00000ba2  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .gnu.version_r 00000040  08048c4c  08048c4c  00000c4c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .rel.dyn      00000020  08048c8c  08048c8c  00000c8c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .rel.plt      00000258  08048cac  08048cac  00000cac  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .init         00000017  08048f04  08048f04  00000f04  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 10 .plt          000004c0  08048f1c  08048f1c  00000f1c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 11 .text         0071cd18  080493e0  080493e0  000013e0  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 12 .fini         0000001d  087660f8  087660f8  0071e0f8  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 13 .rodata       0001ef08  08766120  08766120  0071e120  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 14 .eh_frame_hdr 0000001c  08785028  08785028  0073d028  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 .data         00110930  08786060  08786060  0073d060  2**5
                  CONTENTS, ALLOC, LOAD, DATA
 16 .eh_frame     0000005c  08896990  08896990  0084d990  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 .dynamic      000000d0  088969ec  088969ec  0084d9ec  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 18 .ctors        00000008  08896abc  08896abc  0084dabc  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 19 .dtors        00000008  08896ac4  08896ac4  0084dac4  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 20 .jcr          00000004  08896acc  08896acc  0084dacc  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 21 .got          00000140  08896ad0  08896ad0  0084dad0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 22 .bss          0000800c  08896c20  08896c20  0084dc20  2**5
                  ALLOC
 23 .comment      0000122d  00000000  00000000  0084dc20  2**0
                  CONTENTS, READONLY

> It does look like a bad strip, but I am a bit confused as to why we see the
> error and C compiled programs do not.  (I assume that they don't.)

Right.  I checked the Debian bug reports and could find no mention of
this problem.

> Do we always have problems running all MLton compiled executables when
> stripped, or only sometimes?

I am currently running regressions with a strip after each compile.
So far, all have succeeded.

Now, for some even weirder behavior.  /usr/bin strip on my Debian
machine is nondeterministic.  I was going to report on the differences
between an unstripped and stripped mlton-compile, so I started with
mlton-compile.orig, stripped it, and ran it.  Sadly, the stripped
version now worked!  Furthermore, it was byte for byte identical to
the correctly stripped version from my redhat machine.  To be sure I
am not insane, I ran the following command.

while true; do 
	echo testing; 
	cp mlton-compile.orig mlton-compile && 
	strip mlton-compile && 
	cmp mlton-compile mlton-compile.good; 
done

I would expect this to print the following two lines over and over

	testing
	mlton-compile mlton-compile.good differ: char 472025, line 623

However, it did not.  It usually prints those two lines.  But
occasionally (roughly 1 in 10 times) it just prints testing --
i.e. strip produced the "good" output.

This also jibes with what I was seeing with Debian packaging.
Occasionally, things would just work, but I would usually see the
segfault.

At this point I am completely baffled.



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel