This is the mail archive of the
frysk@sources.redhat.com
mailing list for the frysk project.
Re: frysk-imports frysk/proc/ChangeLog frysk/proc/ ...
- From: Mark Wielaard <mark at klomp dot org>
- To: frysk at sourceware dot org
- Date: Fri, 11 Aug 2006 15:39:41 +0200
- Subject: Re: frysk-imports frysk/proc/ChangeLog frysk/proc/ ...
- References: <20060811072652.414.qmail@sourceware.org>
Hi,
On Fri, 2006-08-11 at 07:26 +0000, moore@sourceware.org wrote:
> 2006-08-11 Tim Moore <timoore@redhat.com>
>
> bz 3014, 3032
> * Elf.java (close): New method to explicity clean up the libelf
> object.
> * cni/Elf.cxx (elf_begin): Store the file descriptor for later
> use. Close it if there's an error creating the Elf object.
> (elf_end): Close the file descriptor used to access the Elf file.
O, the joys of combining manual resource management with a garbage
collector finalization scheme. When we explicitly clean up the Elf file
descriptor we have to be careful that the garbage collector doesn't kick
in later and closes it again. If it does and the file descriptor number
has been reused it will close a descriptor that might be in use!
Luckily the fix is easy:
2006-08-11 Mark Wielaard <mark@klomp.org>
* frysk-imports/lib/elf/cni/Elf.cxx (elf_end): Set fd field to -1.
Committed,
Mark
diff -u -r1.18 Elf.cxx
--- frysk-imports/lib/elf/cni/Elf.cxx 11 Aug 2006 07:26:52 -0000
1.18
+++ frysk-imports/lib/elf/cni/Elf.cxx 11 Aug 2006 13:31:09 -0000
@@ -116,7 +116,10 @@
lib::elf::Elf::elf_end(){
jint val = ::elf_end((::Elf*) this->pointer);
if (fd >= 0)
+ {
::close(fd);
+ fd = -1;
+ }
return val;
}