Last Comment Bug 661800 - elfhack/elf.cpp:285: Elf::Elf(std::ifstream&): Assertion `segment->getFileSize() == phdr.p_filesz' failed.
: elfhack/elf.cpp:285: Elf::Elf(std::ifstream&): Assertion `segment->getFileSiz...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Build Config (show other bugs)
: unspecified
: x86_64 Linux
: -- normal (vote)
: mozilla7
Assigned To: Mike Hommey [:glandium]
:
: Gregory Szorc [:gps]
Mentors:
Depends on: 676198
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-03 06:16 PDT by Octoploid
Modified: 2011-08-03 01:39 PDT (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
libnspr4.so (457.28 KB, application/octet-stream)
2011-06-03 07:04 PDT, Octoploid
no flags Details
test.so (47.91 KB, application/octet-stream)
2011-06-03 07:55 PDT, Octoploid
no flags Details
test.so.bak (59.76 KB, application/octet-stream)
2011-06-03 07:56 PDT, Octoploid
no flags Details
Avoid elfhack considering non SHF_TLS sections as part of PT_TLS segment (1.81 KB, patch)
2011-06-03 19:35 PDT, Mike Hommey [:glandium]
taras.mozilla: review+
Details | Diff | Splinter Review
part 0 - Add a dependency of host_elf*.o upon elfxx.h, to circumvent bug 664362. (888 bytes, patch)
2011-06-15 01:34 PDT, Mike Hommey [:glandium]
ted: review+
Details | Diff | Splinter Review

Description Octoploid 2011-06-03 06:16:42 PDT
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:7.0a1) Gecko/20100101 Firefox/7.0a1
Build Identifier: 

I've hit the following assertion in elfhack:

===
=== If you get failures below, please file a bug describing the error
=== and your environment (compiler and linker versions), and use
=== --disable-elf-hack until this is fixed.
===
cd ../../dist/bin; find . -name "*.so" | xargs ../../build/unix/elfhack/elfhack
./libnspr4.so: Already elfhacked. Skipping
./libplds4.so: No gain. Skipping
./libplc4.so: No gain. Skipping
./libmozsqlite3.so: Reduced by 8032 bytes
./libnssdbm3.so: No gain. Skipping
./libsmime3.so: No gain. Skipping
./libxpcom.so: No gain. Skipping
./libmozalloc.so: No gain. Skipping
./components/libmozgnome.so: No gain. Skipping
./components/libdbusservice.so: No gain. Skipping
./components/libnkgnomevfs.so: No gain. Skipping
./components/libbrowsercomps.so: Reduced by 12128 bytes
./libnssckbi.so: Already elfhacked. Skipping
./libsoftokn3.so: Already elfhacked. Skipping
./libnss3.so: Already elfhacked. Skipping
./libnssutil3.so: Already elfhacked. Skipping
./libssl3.so: Already elfhacked. Skipping
./libfreebl3.so: Already elfhacked. Skipping
elfhack: /var/tmp/mozilla-central/build/unix/elfhack/elf.cpp:285: Elf::Elf(std::ifstream&): Assertion `segment->getFileSize() == phdr.p_filesz' failed.
xargs: ../../build/unix/elfhack/elfhack: terminated by signal 6
make[3]: *** [elfhack] Error 125

This only happens with the latest gcc-4.7.0 during a profiledbuild.
A normal build works without problems.

Reproducible: Always
Comment 1 Mike Hommey [:glandium] 2011-06-03 06:33:19 PDT
could you attach the file on which elfhack fails? (I guess it is libxul.so)
Comment 2 Octoploid 2011-06-03 07:04:10 PDT
Created attachment 537136 [details]
libnspr4.so

Both libnspr4.so and libxul.so trigger the same assertion.
I've attached libnspr4.so, because it's smaller.
Comment 3 Octoploid 2011-06-03 07:42:25 PDT
In case someone is wondering about the "Already elfhacked" messages
above. They appear because I forgot to delete the build directory (
that contained a conventional build) before starting the profiledbuild.
Comment 4 Mike Hommey [:glandium] 2011-06-03 07:50:34 PDT
The problem is that elfhack believes the .dynamic section is in the TLS segment. What's weird is that I'd expect that to be caught by the test case. Could you attach $objdir/build/unix/elfhack/test.so as well?
Comment 5 Octoploid 2011-06-03 07:55:57 PDT
Created attachment 537140 [details]
test.so
Comment 6 Octoploid 2011-06-03 07:56:20 PDT
Created attachment 537141 [details]
test.so.bak
Comment 7 Mike Hommey [:glandium] 2011-06-03 19:35:58 PDT
Created attachment 537290 [details] [diff] [review]
Avoid elfhack considering non SHF_TLS sections as part of PT_TLS segment
Comment 8 Octoploid 2011-06-04 00:03:24 PDT
This fixes the problem for me. Many thanks Mike.
Comment 9 (dormant account) 2011-06-06 10:51:15 PDT
Comment on attachment 537290 [details] [diff] [review]
Avoid elfhack considering non SHF_TLS sections as part of PT_TLS segment

rubberstamp
Comment 10 Mike Hommey [:glandium] 2011-06-14 20:21:06 PDT
http://hg.mozilla.org/mozilla-central/rev/d95b370f0f85
Comment 11 Mike Hommey [:glandium] 2011-06-15 00:25:59 PDT
Backed out because of bug 664362
http://hg.mozilla.org/mozilla-central/rev/f6f801cfdf4c
Comment 12 Mike Hommey [:glandium] 2011-06-15 00:27:02 PDT
Alternatively, landing with a clobber forcing thingy would work as well.
Comment 13 Mike Hommey [:glandium] 2011-06-15 01:34:18 PDT
Created attachment 539454 [details] [diff] [review]
part 0 - Add a dependency of host_elf*.o upon elfxx.h, to circumvent bug 664362.

In the end, it's much simpler to do it locally.
Comment 14 Ted Mielczarek [:ted.mielczarek] 2011-06-15 07:40:47 PDT
Comment on attachment 539454 [details] [diff] [review]
part 0 - Add a dependency of host_elf*.o upon elfxx.h, to circumvent bug 664362.

Review of attachment 539454 [details] [diff] [review]:
-----------------------------------------------------------------
Comment 17 Tim Taubert [:ttaubert] 2011-06-16 05:49:08 PDT
After this got merged to m-c, tip doesn't build for me:

=== If you get failures below, please file a bug describing the error
=== and your environment (compiler and linker versions), and use
=== --disable-elf-hack until this is fixed.
===
/home/tim/workspace/mozilla-central/objdir-ff-release/build/unix/elfhack/elfhack -b test.so
test.so: terminate called after throwing an instance of 'std::runtime_error'
  what():  PT_GNU_RELRO segment doesn't start on a section start

I guess this is related?
Comment 18 Patrick McManus [:mcmanus] 2011-06-16 06:32:11 PDT
(In reply to comment #17)
> After this got merged to m-c, tip doesn't build for me:
> 

The tip does not (clobber) build for me either (5a46d17c72ca - 64bit linux)

===
=== If you get failures below, please file a bug describing the error
=== and your environment (compiler and linker versions), and use
=== --disable-elf-hack until this is fixed.
===
/home/mcmanus/src/mozilla2/wd/obj-debug-661036/build/unix/elfhack/elfhack -b test.so
test.so: terminate called after throwing an instance of 'std::runtime_error'
  what():  PT_GNU_RELRO segment doesn't start on a section start
Comment 19 Mike Hommey [:glandium] 2011-06-16 07:04:44 PDT
this is bug 664366, and the most likely relationship between this and that bug is that the test case change triggers the ld bug.

Note You need to log in before you can comment on or make changes to this bug.