Bug 161701

Summary: jcf-dump free() misusage
Product: [Fedora] Fedora Reporter: Colin Walters <walters>
Component: gccAssignee: Tom Tromey <tromey>
Status: CLOSED INSUFFICIENT_DATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: jakub, patrickm, triage, tromey
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: bzcl34nup
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-05-07 00:11:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
fix free() of constant string none

Description Colin Walters 2005-06-26 01:26:55 UTC
Description of problem:

walters@nexus> valgrind --tool=memcheck jcf-dump
~/temp-workspace/yarrr/lib/xmlrpc-1.2-utf8.jar
==19893== Memcheck, a memory error detector for x86-linux.
==19893== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==19893== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==19893== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==19893== For more details, rerun with: -v
==19893==
Reading classes from archive
/home/walters/temp-workspace/yarrr/lib/xmlrpc-1.2-utf8.jar.
[Skipping directory META-INF/]
...
[Skipping directory uk/org/xml/sax/]
[Skipping compressed file uk/org/xml/sax/DocumentHandler.class]
[Skipping compressed file uk/org/xml/sax/Parser.class]
==19893== Invalid free() / delete / delete[]
==19893==    at 0x1B909743: free (vg_replace_malloc.c:152)
==19893==    by 0x8054059: ??? (jcf-dump.c:1140)
==19893==    by 0x6ACD45: __libc_start_main (in /lib/libc-2.3.5.so)
==19893==    by 0x8049370: (within /usr/bin/jcf-dump)
==19893==  Address 0x52BFEA4D is on thread 1's stack
==19893==
==19893== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 14 from 1)
==19893== malloc/free: in use at exit: 324816 bytes in 12 blocks.
==19893== malloc/free: 74 allocs, 63 frees, 400891 bytes allocated.
==19893== For counts of detected errors, rerun with: -v
==19893== searching for pointers to 12 not-freed blocks.
==19893== checked 382152 bytes.
==19893==
==19893== LEAK SUMMARY:
==19893==    definitely lost: 0 bytes in 0 blocks.
==19893==      possibly lost: 0 bytes in 0 blocks.
==19893==    still reachable: 324816 bytes in 12 blocks.
==19893==         suppressed: 0 bytes in 0 blocks.
==19893== Reachable blocks (those to which a pointer was found) are not shown.
==19893== To see them, rerun with: --show-reachable=yes


Version-Release number of selected component (if applicable):
gcc-java-4.0.0-13


How reproducible:
Every time

Comment 1 Colin Walters 2005-06-26 01:26:55 UTC
Created attachment 115984 [details]
fix free() of constant string

Comment 2 Andrew Haley 2005-06-29 12:53:23 UTC
Has this ever produced a bug?


Comment 3 Jakub Jelinek 2005-06-29 13:03:41 UTC
Passing pointer to memory not allocated by {m,c,re,v}alloc, memalign or
posix_memalign to free is always a bug, could result in clobbering program's
memory or various kinds of crashes.

Comment 4 Jakub Jelinek 2005-07-12 11:46:31 UTC
BTW, the above patch is IMHO not enough, there are places in gcj which expect
JCF_FINISH to free the pointer which was passed to open_class (e.g.
parse_zip_file_entries), and there are places like jcf-dump.c that pass not
allocated memory to it.  So I guess an audit is needed and after applying
Colin's patch some places need to be fixed up to free the memory they
allocated.
Even normal glibc free does several consistency check, so it wouldn't surprise
me if you could get jc1 or one of the utilities to crash unless this is fixed.


Comment 5 Tom Tromey 2007-04-04 20:32:09 UTC
I only found this bug last week :(.  I wish I were somehow automatically
CCd on gcj-related PRs.

What a mess this code is.

Comment 6 Tom Tromey 2007-04-04 20:37:07 UTC
Ok, I tracked through this code and I don't see any big problems.
Am I missing something?  I looked at parse_zip_file_entries and
all seems well there, to me.

I think this patch is fine and I am going to check it in.
Even if it is buggy it turns a potential crash into a small
memory leak, which is an improvement.

Comment 7 Tom Tromey 2007-09-01 02:34:47 UTC
FWIW I checked this patch in back in April.

Comment 8 Bug Zapper 2008-04-03 16:13:52 UTC
Based on the date this bug was created, it appears to have been reported
against rawhide during the development of a Fedora release that is no
longer maintained. In order to refocus our efforts as a project we are
flagging all of the open bugs for releases which are no longer
maintained. If this bug remains in NEEDINFO thirty (30) days from now,
we will automatically close it.

If you can reproduce this bug in a maintained Fedora version (7, 8, or
rawhide), please change this bug to the respective version and change
the status to ASSIGNED. (If you're unable to change the bug's version
or status, add a comment to the bug and someone will change it for you.)

Thanks for your help, and we apologize again that we haven't handled
these issues to this point.

The process we're following is outlined here:
http://fedoraproject.org/wiki/BugZappers/F9CleanUp

We will be following the process here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping to ensure this
doesn't happen again.

Comment 9 Bug Zapper 2008-05-07 00:11:56 UTC
This bug has been in NEEDINFO for more than 30 days since feedback was
first requested. As a result we are closing it.

If you can reproduce this bug in the future against a maintained Fedora
version please feel free to reopen it against that version.

The process we're following is outlined here:
http://fedoraproject.org/wiki/BugZappers/F9CleanUp