Bug 10773 - Malformed archive created when adding several files at once
Summary: Malformed archive created when adding several files at once
Status: REOPENED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-14 08:49 UTC by Konrad Schwarz
Modified: 2016-12-16 17:41 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
ar(1) archive containing object files that give ar problems (19.28 KB, application/octet-stream)
2009-10-15 13:24 UTC, Konrad Schwarz
Details
Terminal transcript exhibiting the bug. (573 bytes, text/plain)
2009-10-15 13:39 UTC, Konrad Schwarz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konrad Schwarz 2009-10-14 08:49:42 UTC
Multiple invocations with one file per invocation of ar rv successfully create
an archive, but invoking ar rv with several files at once creates a "Malformed
archive" according to ar t.

I can provide a reproducible test case upon request---I don't see a place to add
attachments in Bugzilla, or I would have added it already.

$ ar V
GNU ar (GNU Binutils; openSUSE 11.1) 2.19
$ uname -a
Linux mchn144c 2.6.27.29-0.1-default #1 SMP 2009-08-15 17:53:59 +0200 x86_64 x86
_64 x86_64 GNU/Linux
Comment 1 Konrad Schwarz 2009-10-15 13:24:40 UTC
Created attachment 4283 [details]
ar(1) archive containing object files that give ar problems

To recreate the bug, use the following procedure:

$ mkdir zip
$ cd zip
$ ar x ../../generated/libosek-b_____gpx_.a; # the attached file
$ ar crv lib1.a *.o
a - ActivateTask-b___gpx_.o
a - alarm_activate.o
a - alarm_callback.o
a - alarm_event.o
a - all_suspend_resume.o
a - apic_timer.o
a - CancelAlarm-b_gpx_.o
a - ChainTask-b___gpx_.o
a - ClearEvent-b_gpx_.o
a - context_swap_tail.o
a - device_not_available.o
a - EnableDisable-x_.o
a - generate_page_table.o
a - GetActiveApplicationMode-_.o
a - GetAlarmBase-b_gpx_.o
a - GetAlarm-b_gpx_.o
a - GetEvent-b_gpx_.o
a - GetResource-b_gpx_.o
a - GetTaskID-x_.o
a - GetTaskState-b_gpx_.o
a - idle_loop.o
a - in_error_handling_routine-_.o
a - interval_timer_disable.o
a - interval_timer_enable.o
a - interval_timer_init.o
a - interval_timer_isr.o
a - interval_timer_now.o
a - isr_holds_resource.o
a - longjmp.o
a - map_segment.o
a - osek_counter_process-b.o
a - osek_heapsort-b.o
a - OSError_OSParameter-p.o
a - OSError_OSServiceId-g.o
a - page_table_page_alloc.o
a - processor_context_switch.o
a - ready_mask_0.o
a - ready_mask_1.o
a - ready_mask_2.o
a - ready_mask_3.o
a - ReleaseResource-b___gpx_.o
a - ResumeSuspendOS-x_.o
a - ResumeSuspend-x_.o
a - Schedule-b___gpx_.o
a - SetAbsAlarm-b_gpx_.o
a - SetEvent-b___gpx_.o
a - setjmp.o
a - SetRelAlarm-b_gpx_.o
a - ShutdownOS-x_.o
a - spurious_interrupt.o
a - StartOS-b_____gpx_.o
a - suspend_resume.o
a - task_fell_off_end.o
a - TerminateTask-b___gpx_.o
a - WaitEvent-b___gpx_.o
$ ar t lib1.a; # THIS STEP EXHIBITS THE BUG
ar: lib1.a: Malformed archive
$ for i in *.o;do ar rv lib2.a $i;done
ar: creating lib2.a
a - ActivateTask-b___gpx_.o
a - alarm_activate.o
a - alarm_callback.o
a - alarm_event.o
a - all_suspend_resume.o
a - apic_timer.o
a - CancelAlarm-b_gpx_.o
a - ChainTask-b___gpx_.o
a - ClearEvent-b_gpx_.o
a - context_swap_tail.o
a - device_not_available.o
a - EnableDisable-x_.o
a - generate_page_table.o
a - GetActiveApplicationMode-_.o
a - GetAlarmBase-b_gpx_.o
a - GetAlarm-b_gpx_.o
a - GetEvent-b_gpx_.o
a - GetResource-b_gpx_.o
a - GetTaskID-x_.o
a - GetTaskState-b_gpx_.o
a - idle_loop.o
a - in_error_handling_routine-_.o
a - interval_timer_disable.o
a - interval_timer_enable.o
a - interval_timer_init.o
a - interval_timer_isr.o
a - interval_timer_now.o
a - isr_holds_resource.o
a - longjmp.o
a - map_segment.o
a - osek_counter_process-b.o
a - osek_heapsort-b.o
a - OSError_OSParameter-p.o
a - OSError_OSServiceId-g.o
a - page_table_page_alloc.o
a - processor_context_switch.o
a - ready_mask_0.o
a - ready_mask_1.o
a - ready_mask_2.o
a - ready_mask_3.o
a - ReleaseResource-b___gpx_.o
a - ResumeSuspendOS-x_.o
a - ResumeSuspend-x_.o
a - Schedule-b___gpx_.o
a - SetAbsAlarm-b_gpx_.o
a - SetEvent-b___gpx_.o
a - setjmp.o
a - SetRelAlarm-b_gpx_.o
a - ShutdownOS-x_.o
a - spurious_interrupt.o
a - StartOS-b_____gpx_.o
a - suspend_resume.o
a - task_fell_off_end.o
a - TerminateTask-b___gpx_.o
a - WaitEvent-b___gpx_.o
$ ar t lib2.a; # NO PROBLEM HERE
ActivateTask-b___gpx_.o
alarm_activate.o
alarm_callback.o
alarm_event.o
all_suspend_resume.o
apic_timer.o
CancelAlarm-b_gpx_.o
ChainTask-b___gpx_.o
ClearEvent-b_gpx_.o
context_swap_tail.o
device_not_available.o
EnableDisable-x_.o
generate_page_table.o
GetActiveApplicationMode-_.o
GetAlarmBase-b_gpx_.o
GetAlarm-b_gpx_.o
GetEvent-b_gpx_.o
GetResource-b_gpx_.o
GetTaskID-x_.o
GetTaskState-b_gpx_.o
idle_loop.o
in_error_handling_routine-_.o
interval_timer_disable.o
interval_timer_enable.o
interval_timer_init.o
interval_timer_isr.o
interval_timer_now.o
isr_holds_resource.o
longjmp.o
map_segment.o
osek_counter_process-b.o
osek_heapsort-b.o
OSError_OSParameter-p.o
OSError_OSServiceId-g.o
page_table_page_alloc.o
processor_context_switch.o
ready_mask_0.o
ready_mask_1.o
ready_mask_2.o
ready_mask_3.o
ReleaseResource-b___gpx_.o
ResumeSuspendOS-x_.o
ResumeSuspend-x_.o
Schedule-b___gpx_.o
SetAbsAlarm-b_gpx_.o
SetEvent-b___gpx_.o
setjmp.o
SetRelAlarm-b_gpx_.o
ShutdownOS-x_.o
spurious_interrupt.o
StartOS-b_____gpx_.o
suspend_resume.o
task_fell_off_end.o
TerminateTask-b___gpx_.o
WaitEvent-b___gpx_.o
Comment 2 Konrad Schwarz 2009-10-15 13:34:49 UTC
Comment on attachment 4283 [details]
ar(1) archive containing object files that give ar problems

To recreate the bug,

$ mkdir zip
$ cd zip
$ ar x ../../generated/libosek-b_____gpx_.a
$ ar cr lib1.a *.o
$ ar t lib1.a
ar: lib1.a: Malformed archive
$ for i in *.o;do ar cr lib2.a $i;done
$ ar t lib2.a
ActivateTask-b___gpx_.o
alarm_activate.o
alarm_callback.o
alarm_event.o
all_suspend_resume.o
apic_timer.o
CancelAlarm-b_gpx_.o
ChainTask-b___gpx_.o
ClearEvent-b_gpx_.o
context_swap_tail.o
device_not_available.o
EnableDisable-x_.o
generate_page_table.o
GetActiveApplicationMode-_.o
GetAlarmBase-b_gpx_.o
GetAlarm-b_gpx_.o
GetEvent-b_gpx_.o
GetResource-b_gpx_.o
GetTaskID-x_.o
GetTaskState-b_gpx_.o
idle_loop.o
in_error_handling_routine-_.o
interval_timer_disable.o
interval_timer_enable.o
interval_timer_init.o
interval_timer_isr.o
interval_timer_now.o
isr_holds_resource.o
longjmp.o
map_segment.o
osek_counter_process-b.o
osek_heapsort-b.o
OSError_OSParameter-p.o
OSError_OSServiceId-g.o
page_table_page_alloc.o
processor_context_switch.o
ready_mask_0.o
ready_mask_1.o
ready_mask_2.o
ready_mask_3.o
ReleaseResource-b___gpx_.o
ResumeSuspendOS-x_.o
ResumeSuspend-x_.o
Schedule-b___gpx_.o
SetAbsAlarm-b_gpx_.o
SetEvent-b___gpx_.o
setjmp.o
SetRelAlarm-b_gpx_.o
ShutdownOS-x_.o
spurious_interrupt.o
StartOS-b_____gpx_.o
suspend_resume.o
task_fell_off_end.o
TerminateTask-b___gpx_.o
WaitEvent-b___gpx_.o
Comment 3 Konrad Schwarz 2009-10-15 13:39:01 UTC
Created attachment 4284 [details]
Terminal transcript exhibiting the bug.
Comment 4 Alan Modra 2009-10-16 01:52:30 UTC
I could not reproduce this problem.  I tried with many different versions of ar.
Comment 5 Alan Modra 2010-01-12 02:50:23 UTC
Likely a filesystem bug
Comment 6 Konrad Schwarz 2010-01-12 09:52:28 UTC
(In reply to comment #5)
> Likely a filesystem bug

Actually, the bug went away went I stopped mixing 32 and 64 bit x86 ELF object
files in a single archive.  I am almost 100% sure this is the actual cause.

I consider a file system bug unlikely, as I am running on a stock Open SuSE
distribution, I have noticed no other problems in the file system, and the
problem was 100% reproducible on my system when mixing different object file
types, but did not occur when using object files of a single type.

Mixing 32 and 64 bit objects in one archive is certainly a borderline case. 
However, GNU ld accepts such archives without a problem.

Furthermore, a feature of ar(1) in traditional Unixes (always touted in the
manuals) was that, if the archive contained only printable files, the entire
archive itself was printable; hence the p option to ar.  It follows that ar is
required to archive arbitrary file types.

Thus, I still consider this behavior erroneous and ar buggy.
Comment 7 Alan Modra 2010-01-12 13:47:37 UTC
As I said I could not reproduce this bug with many different versions of FSF
binutils.  Have you built a version of FSF binutils that exhibits this bug?  If
so, I'd like to know which version and the arguments you passed to configure. 
If not, then please report this bug to SUSE as it might be caused by some patch
they added to binutils.
Comment 8 Konrad Schwarz 2010-01-12 15:37:05 UTC
(In reply to comment #7)
> As I said I could not reproduce this bug with many different versions of FSF
> binutils.  Have you built a version of FSF binutils that exhibits this bug?  If
> so, I'd like to know which version and the arguments you passed to configure. 
> If not, then please report this bug to SUSE as it might be caused by some patch
> they added to binutils.

Just tested with binutils-2.20.  Works for me, too, even with the system
supplied ar.  Bug does not appear.  I can't explain it;
the transcript provided in the bug report were taken verbatim from the terminal.

Sorry for wasting your time.

If the bug reoccurs, I will try to debug it myself.
Comment 9 Jason Spangler 2015-12-21 21:26:13 UTC
I know this is an old bug entry, but this was the only place on the net I found this bug mentioned.

I was just hit by the same bug symptoms as the reporter: ar crv lib1.a *.o generated a "Malformed archive" (unless the .o files were still present in the directory), but ar cr lib2.a ${filename} individually on each file creates a valid archive.

I'm running CentOS 7 with changes, and binutils 2.23 from the rpm package binutils-2.23.52.0.1-30.el7_1.2.x86_64 .
Comment 10 Nick Clifton 2015-12-22 11:17:15 UTC
Hi Jason, 

> I was just hit by the same bug symptoms as the reporter:  
> 
> I'm running CentOS 7 with changes, and binutils 2.23 from the rpm package
> binutils-2.23.52.0.1-30.el7_1.2.x86_64 .

Is there any chance that you could test to see if this problem still happens with a more recent binutils release, say version 2.25 perhaps ?

Cheers
  Nick
Comment 11 Jason Spangler 2016-01-21 17:33:22 UTC
I just tried with binutils-2.25.1 from RPM binutils-2.25.1-9.fc24.x86_64 and the same problem occurred.

(In reply to Nick Clifton from comment #10)
> Hi Jason, 
> 
> > I was just hit by the same bug symptoms as the reporter:  
> > 
> > I'm running CentOS 7 with changes, and binutils 2.23 from the rpm package
> > binutils-2.23.52.0.1-30.el7_1.2.x86_64 .
> 
> Is there any chance that you could test to see if this problem still happens
> with a more recent binutils release, say version 2.25 perhaps ?
> 
> Cheers
>   Nick
Comment 12 Nick Clifton 2016-01-22 09:30:32 UTC
Hi Jason,

> I just tried with binutils-2.25.1 from RPM binutils-2.25.1-9.fc24.x86_64 and
> the same problem occurred.

In which case, please could you upload a testcase for us to try out ?

Cheers
  Nick
Comment 13 Michele 2016-12-16 17:41:18 UTC
I noticed that when I had a Malformed archive for building geotiff for linux, we had switched the linux dir to un-matching things in different cases.  For example, our linux version from the command line is 4.4.4.  In the makefile, the linux LIB_DIR is linux64_gcc46/lib.  However, the geotiff subdir had a dependency on proj and tiff, which had different LIB_DIR names than that for the linux lib.  Once I got them all matching up, the AR command in the makefile did not have an error.