Bug 1082370 - -shared -g3 can trigger terrabyte+ mallocs() in ld
Summary: -shared -g3 can trigger terrabyte+ mallocs() in ld
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: binutils
Version: 20
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Nick Clifton
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-30 20:35 UTC by Dave Mitchell
Modified: 2015-06-30 00:57 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-06-30 00:57:58 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
sample failing C code (1.87 KB, text/x-csrc)
2014-03-30 20:35 UTC, Dave Mitchell
no flags Details
Check for pathalogical debug strings (962 bytes, patch)
2014-04-28 14:50 UTC, Nick Clifton
no flags Details | Diff

Description Dave Mitchell 2014-03-30 20:35:41 UTC
Created attachment 880480 [details]
sample failing C code

Description of problem:

Compiling the attached trivial c file triggers "Memory exhausted" errors in ld.
An strace shows it trying to mmap 6869754501689204736 bytes.


Version-Release number of selected component (if applicable):

gcc-4.8.2-7.fc20.x86_64
also, binutils-2.23.88.0.1-13.fc20.x86_64.
Problem also occurred on F18.

How reproducible:

Steps to Reproduce:

1. Save the attachment as foo.c somewhere.
2. /usr/bin/cc -c -g3 -fstack-protector -fPIC  foo.c
3. /usr/bin/cc -shared -g3 foo.o -o /tmp/foo.so


Actual results:

$ /usr/bin/cc -shared -g3 foo.o -o /tmp/foo.so
/usr/bin/ld: final link failed: Memory exhausted
collect2: error: ld returned 1 exit status
$



Expected results:

No error.


Additional info:

Comment 1 Jakub Jelinek 2014-04-28 07:35:25 UTC
I don't see any issues on the side of code generated by gcc.
Furthermore, it links just fine with -fuse-ld=gold, therefore I'd say it is a ld.bfd bug.

Comment 2 Nick Clifton 2014-04-28 14:50:01 UTC
Created attachment 890516 [details]
Check for pathalogical debug strings

It is not a GCC bug true - but it is a special case.  The debug strings generated by the test program just happen to include "ZLIB" as the first four characters of the .debug_str section.  The BFD library detects this and assumes that the section has been compressed by the zlib library and that it needs to be decompressed...

Since the next 8 bytes in a compressed section are the uncompressed size, the BFD library reads these in and so converts "_VER_SUB" into a size, which naturally enough is too big for the linker to handle.

The uploaded patch should fix this.  I am running it through regression tests now.

Comment 3 Nick Clifton 2014-04-28 15:57:56 UTC
Fixed in:
 binutils-2.23.88.0.1-17.fc20
 binutils-2.24-13.fc21

Comment 4 Fedora End Of Life 2015-05-29 11:24:51 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2015-06-30 00:57:58 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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