This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: frysk-imports frysk/proc/ChangeLog frysk/proc/ ...


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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]