linker causes dynamic_cast failure with compact_linkedit

Originator:fangism
Number:rdar://7512422 Date Originated:2010-01-05
Status:Duplicate/7246093 Resolved:
Product:Developer Tools Product Version:3.2.1
Classification:serious bug Reproducible:Always
 
05-Jan-2010 06:34 PM David Fang:
Summary: ld linking issue without -no_compact_linkedit
Exposed as a run-time dynamic_cast failure on 10.6.

To apple dev tools team:
instructions for reproducing bug(?)

Version (Developer Tools):
Bug is reproducible only on darwin10, not darwin9 or earlier.

The test case provided fails on 10.6 across the various compiler's I've tried:
apple-gcc-4.0, apple-gcc-4.2, FSF-gcc-4.4.
gcc version 4.2.1 (Apple Inc. build 5646) (dot 1)
gcc version 4.0.1 (Apple Inc. build 5493)

Hardware: 13" Intel Macbook
System: OS X 10.6.2

This test case has been difficult to reduce, as the executable involved
builds against shared libraries, so I've shipped the whole package.

prerequisites:
flex 2.5.4, but just for this test case, version doesn't matter
/usr/bin/yacc is sufficient

source: http://www.csl.cornell.edu/~fang/hackt/dists/hackt-0.1.4-devel-20100105.tar.bz2

unpack:
tar xjvf <source>.tar.bz2

build:
cd <srcdir>
mkdir build-bad build-good

cd build-bad
../configure YACC=/usr/bin/yacc
make

# also
cd build-good
../configure YACC=/usr/bin/yacc LDFLAGS="-Wl,-no_compact_linkedit"
make

I recommend MAKEFLAGS=-j4 or however many CPUs you got.
The compile takes a rather long time.

run:
[in both build-bad/src and build-good/src, run:]
./cast_test

you should see:
\-{ void expanded_test(std::ostream&)
dp @ 0x14159ac

dp->what(): bool-inst-ref
rcdp = 0x14159a0

/-} void expanded_test(std::ostream&)

but the failed test shows:
\-{ void expanded_test(std::ostream&)
dp @ 0x26159ac
dp->what(): bool-inst-ref
rcdp = 0

Assertion failed: (rcdp), function expanded_test, file ../../../src/test/cast_test.cc, line 99.

This test SHOULD pass, but it fails without LDFLAGS=-Wl,-no_compact_linkedit
which was introduced in 10.6.

Problem is deterministically reproducible, as a normal user.

Don't hesitate to contact me by email <fang@csl.cornell.edu>,
I'm willing to answer questions to the engineering team to get this resolved ASAP.

David Fang

Comments

known issue in database

from Apple:

This is a follow up to Bug ID# 7512422. After further investigation it has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 7246093. The original bug number being used to track this duplicate issue can be found in the State column, in this format: Duplicate/OrigBug#.

flex version

This initial tarball was not able to compile against flex 2.5.35, but only with flex 2.5.4. (You can pass LEX=... as a configure option) I've updated the source so that both versions of flex will compile and demonstrate the problem. Let me know if you need this updated tarball.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!