Bug 766156 - eu-strip doesn't handle ar archive library
Summary: eu-strip doesn't handle ar archive library
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: elfutils
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mark Wielaard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-12-10 17:35 UTC by David Howells
Modified: 2017-04-02 17:57 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-14 02:15:40 UTC
Type: ---


Attachments (Terms of Use)
A sample archive library (47.24 KB, application/x-archive)
2011-12-10 17:35 UTC, David Howells
no flags Details

Description David Howells 2011-12-10 17:35:14 UTC
Created attachment 544932 [details]
A sample archive library

Description of problem:

The eu-strip program dies with a segmentation fault when given an archive library.  Ordinary strip does not.

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

elfutils-0.152-1.fc16

How reproducible:

100%.

Steps to Reproduce:
1. Grab the attached libgcov.a.
2. eu-strip libgcov.a
  
Actual results:

SEGV.  libgcov.a is now a broken ELF object file.

Expected results:

It should work and leave an archive library.

Additional info:

Program received signal SIGSEGV, Segmentation fault.
0x00000034850044e3 in elf_end (elf=0x60d220) at elf_end.c:119
119               while (child->next != elf)
(gdb) bt
#0  0x00000034850044e3 in elf_end (elf=0x60d220) at elf_end.c:119
#1  0x0000000000402bf5 in handle_elf (fd=7, elf=<optimized out>, prefix=<optimized out>, mode=4294958400, tvp=0x0) at strip.c:1806
#2  0x0000000000405d54 in handle_ar (fd=7, elf=0x60c030, prefix=<optimized out>, fname=0x7fffffffe54c "libgcov.a", tvp=0x0) at strip.c:1881
#3  0x000000000040611d in process_file (fname=0x7fffffffe54c "libgcov.a") at strip.c:365
#4  0x00000000004021e3 in main (argc=2, argv=0x7fffffffe178) at strip.c:197
(gdb) i lo
child = 0x0
parent = 0x60c030
__PRETTY_FUNCTION__ = "elf_end"

Comment 1 Petr Machata 2011-12-14 19:37:48 UTC
This happens for all archives, not only archives from non-native architectures.  The following is on x86_64:
$ gcc -x c /dev/null -c -o null.o
$ ar cru null.a null.o
$ eu-strip null.a 
Segmentation fault

The apparent reason is that elf_clone doesn't add the cloned elf among parent's children.  After doing that, it doesn't segv, but the archive is broken anyway.  I'm looking further.

Comment 3 Petr Machata 2011-12-14 19:54:46 UTC
Yes, I was just about to post about the same.  Something was at the back of my mind about strip and archives.

Comment 4 Fedora End Of Life 2013-02-14 02:15:44 UTC
Fedora 16 changed to end-of-life (EOL) status on 2013-02-12. Fedora 16 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.

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

Comment 5 Mark Wielaard 2013-02-14 08:26:11 UTC
This seems to be a long standing problem not yet resolved.

Note the list archive of the messages from comment #2 have moved:
https://lists.fedorahosted.org/pipermail/elfutils-devel/2009-August/000567.html
https://lists.fedorahosted.org/pipermail/elfutils-devel/2011-November/002162.html

Comment 6 Fedora End Of Life 2013-04-03 19:38:57 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 7 Mark Wielaard 2015-06-08 13:31:13 UTC
This will still crash eu-strip with current elfutils git.

Comment 8 Mark Wielaard 2015-06-11 11:12:34 UTC
I pushed a patch to make eu-strip just print an error when trying to strip an archive. That obviously isn't very helpful, but it is better than crashing or (silently) corrupting archives.

We should rework eu-strip as outlined by Roland in:
https://lists.fedorahosted.org/pipermail/elfutils-devel/2009-August/000567.html


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