This is the mail archive of the 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/ ...


On Fri, 2006-08-11 at 07:26 +0000, wrote:
> 	2006-08-11  Tim Moore  <>
> 	bz 3014, 3032
> 	* (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  <>

    * frysk-imports/lib/elf/cni/Elf.cxx (elf_end): Set fd field to -1.



diff -u -r1.18 Elf.cxx
--- frysk-imports/lib/elf/cni/Elf.cxx   11 Aug 2006 07:26:52 -0000
+++ frysk-imports/lib/elf/cni/Elf.cxx   11 Aug 2006 13:31:09 -0000
@@ -116,7 +116,10 @@
        jint val = ::elf_end((::Elf*) this->pointer);
        if (fd >= 0)
+          {
+                fd = -1;
+          }
        return val;

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