Bug 161701 - jcf-dump free() misusage
jcf-dump free() misusage
Status: CLOSED INSUFFICIENT_DATA
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tom Tromey
bzcl34nup
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-25 21:26 EDT by Colin Walters
Modified: 2014-08-11 01:46 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-05-06 20:11:58 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
fix free() of constant string (490 bytes, patch)
2005-06-25 21:26 EDT, Colin Walters
no flags Details | Diff

  None (edit)
Description Colin Walters 2005-06-25 21:26:55 EDT
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-25 21:26:55 EDT
Created attachment 115984 [details]
fix free() of constant string
Comment 2 Andrew Haley 2005-06-29 08:53:23 EDT
Has this ever produced a bug?
Comment 3 Jakub Jelinek 2005-06-29 09:03:41 EDT
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 07:46:31 EDT
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 16:32:09 EDT
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 16:37:07 EDT
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-08-31 22:34:47 EDT
FWIW I checked this patch in back in April.
Comment 8 Bug Zapper 2008-04-03 12:13:52 EDT
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-06 20:11:56 EDT
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

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