elfhack/elf.cpp:285: Elf::Elf(std::ifstream&): Assertion `segment->getFileSize() == phdr.p_filesz' failed.

RESOLVED FIXED in mozilla7

Status

()

Core
Build Config
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Octoploid, Assigned: glandium)

Tracking

(Depends on: 1 bug)

unspecified
mozilla7
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(5 attachments)

(Reporter)

Description

6 years ago
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
could you attach the file on which elfhack fails? (I guess it is libxul.so)
(Reporter)

Comment 2

6 years ago
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.
Assignee: nobody → mh+mozilla
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(Reporter)

Comment 3

6 years ago
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.
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?
(Reporter)

Comment 5

6 years ago
Created attachment 537140 [details]
test.so
(Reporter)

Comment 6

6 years ago
Created attachment 537141 [details]
test.so.bak
Created attachment 537290 [details] [diff] [review]
Avoid elfhack considering non SHF_TLS sections as part of PT_TLS segment
Attachment #537290 - Flags: review?(tglek)
(Reporter)

Comment 8

6 years ago
This fixes the problem for me. Many thanks Mike.

Comment 9

6 years ago
Comment on attachment 537290 [details] [diff] [review]
Avoid elfhack considering non SHF_TLS sections as part of PT_TLS segment

rubberstamp
Attachment #537290 - Flags: review?(tglek) → review+
http://hg.mozilla.org/mozilla-central/rev/d95b370f0f85
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla7
Backed out because of bug 664362
http://hg.mozilla.org/mozilla-central/rev/f6f801cfdf4c
Status: RESOLVED → REOPENED
Depends on: 664362
Resolution: FIXED → ---
Alternatively, landing with a clobber forcing thingy would work as well.
Depends on: 660015
Target Milestone: mozilla7 → ---
No longer depends on: 660015, 664362
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.
Attachment #539454 - Flags: review?(ted.mielczarek)
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]:
-----------------------------------------------------------------
Attachment #539454 - Flags: review?(ted.mielczarek) → review+
http://hg.mozilla.org/integration/mozilla-inbound/rev/0640c9ecfba2
http://hg.mozilla.org/integration/mozilla-inbound/rev/6e3813929a57
Whiteboard: [inbound]
Merged in m-c
http://hg.mozilla.org/mozilla-central/rev/0640c9ecfba2
http://hg.mozilla.org/mozilla-central/rev/6e3813929a57
Status: REOPENED → RESOLVED
Last Resolved: 6 years ago6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla7
Whiteboard: [inbound]
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?
(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
this is bug 664366, and the most likely relationship between this and that bug is that the test case change triggers the ld bug.
Depends on: 664366
No longer depends on: 664366
Depends on: 676198
You need to log in before you can comment on or make changes to this bug.