View Issue Details

IDProjectCategoryView StatusLast Update
0015278FPCCompilerpublic2010-05-18 19:52
ReporterSeth Grover Assigned ToJonas Maebe  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Platformx86OSUbuntu Linux 
Product Version2.3.1 
Summary0015278: "Inconsistency detected by ld.so" when compiling
DescriptionAfter compiling and linking tw12704a.pp and tw12704b.pp in the tests on Ubuntu Linux 9.10 with FreePascal 2.4.0 (from the tags/release_2_4_0 tag in subversion) and then running it, ld.so complains with an error:

====================================================
user@localhost:~/tmp$ export LD_LIBRARY_PATH=.
user@localhost:~/tmp$ fpc tw12704a.pp
Free Pascal Compiler version 2.4.0 [2009/12/07] for i386
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for i386
Compiling tw12704a.pp
tw12704a.pp(23,3) Note: Local variable "p" not used
Linking libtw12704a.so
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
107 lines compiled, 0.2 sec
1 note(s) issued
user@localhost:~/tmp$ fpc tw12704b.pp
Free Pascal Compiler version 2.4.0 [2009/12/07] for i386
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for i386
Compiling tw12704b.pp
tw12704b.pp(22,3) Note: Local variable "p" not used
Linking tw12704b
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
49 lines compiled, 0.1 sec
1 note(s) issued
user@localhost:~/tmp$ ldd libtw12704a.so
    statically linked
user@localhost:~/tmp$ ldd tw12704b
    linux-gate.so.1 => (0x0021c000)
    libtw12704a.so => ./libtw12704a.so (0x00f0a000)
user@localhost:~/tmp$ ./tw12704b
Inconsistency detected by ld.so: dl-fini.c: 195: _dl_fini: Assertion `ns != 0 || i == nloaded' failed!
====================================================

However, if i add libc to the uses clause of tw12704b.pp I get no error.
Steps To ReproduceMost of the feedback I've gotten from the mailing list about this issue is that I've got something wrong in my setup. However, to eliminate me doing anything wrong personally, here's what I did:

1. Create a virtual machine and install a stock 32-bit Ubuntu 9.10 installation
2. After it boots for the first time, install the "build-essential" and
   "subversion" packages. I did not alter the distribution in ANY other way
   other than installing these two packages.
3. check out http://svn.freepascal.org/svn/fpc/tags/release_2_4_0 from svn
4. compile (make clean all) and install (sudo make install) freepascal. I
   used a ppc386 I extracted from the sourceforge debs to compile the
   compiler, then I used samplecfg to generate my /etc/fpc.cfg
5. Compile and run the tw12704a and tw12704b tests as I did in the description.

As far as I can see, there's no way it's something I'm going wrong.
Additional InformationAfter I did the steps to reproduce, I had a though and reverted to a snapshot in my VM before I started installing fpc from svn. I installed the fpc 2.2.4 from the standard ubuntu repositories and could not reproduce the problem. So it appears to be something changed in FPC recently (?).
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

Seth Grover

2009-12-07 17:48

reporter   ~0032791

I'm sorry, I just realized the summary for the bug wasn't very descriptive. I meant it to be:

"Inconsistency detected by ld.so" when compiling and running tw12704a/tw12704b tests

Jonas Maebe

2010-01-07 17:10

manager   ~0033497

The feedback was not specifically about you having made an error in your setup, but about there being a bug in the dynamic linker you use.

The difference between including the libc unit and not including it, is that if you include it, then your dynamic library itself will also be dynamically linked (only including the initc unit rather than the legacy libc unit is probably enough) rather than statically linked. There may be problems in the version of (e)glibc (the dynamic linker is part of (e)glibc) you have with directly linking to statically linked dynamic libraries, as there have been such problems in the past as well (see e.g. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=227906)

Please file a bug report with Ubuntu, since as far as I can tell this is not an FPC problem.

Jonas Maebe

2010-01-07 17:53

manager   ~0033498

You may also want to test with FPC 2.5.1 (i.e., trunk), as the library initialisation code was largely rewritten there.

Seth Grover

2010-01-08 23:08

reporter   ~0033522

I tried with 2.5.1 (rev 14581, current) with the same effect.

$ ./tw12704b
Inconsistency detected by ld.so: dl-fini.c: 195: _dl_fini: Assertion `ns != 0 || i == nloaded' failed!

Jonas Maebe

2010-01-08 23:41

manager   ~0033523

Then I really think it is a problem in the dynamic linker.

Issue History

Date Modified Username Field Change
2009-12-07 17:47 Seth Grover New Issue
2009-12-07 17:48 Seth Grover Note Added: 0032791
2010-01-07 17:10 Jonas Maebe Status new => resolved
2010-01-07 17:10 Jonas Maebe Resolution open => no change required
2010-01-07 17:10 Jonas Maebe Assigned To => Jonas Maebe
2010-01-07 17:10 Jonas Maebe Note Added: 0033497
2010-01-07 17:53 Jonas Maebe Note Added: 0033498
2010-01-08 23:08 Seth Grover Status resolved => feedback
2010-01-08 23:08 Seth Grover Resolution no change required => reopened
2010-01-08 23:08 Seth Grover Note Added: 0033522
2010-01-08 23:41 Jonas Maebe Status feedback => resolved
2010-01-08 23:41 Jonas Maebe Resolution reopened => no change required
2010-01-08 23:41 Jonas Maebe Note Added: 0033523
2010-05-18 19:52 Seth Grover Status resolved => closed