Re: [libvirt-java] [PATCH 11/65] Use virFree in order to release memory acquired from libvirt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 13, 2014 at 04:22:19PM +0100, Claudio Bley wrote:
> When JNA is linked to a different runtime library than libvirt, using
> JNA's Native.free will probably lead to crashes as witnessed on
> Windows:
> 
>  # A fatal error has been detected by the Java Runtime Environment:
>  #
>  #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000077363290, pid=10180, tid=9908
>  #
>  # JRE version: 7.0_25-b16
>  # Java VM: Java HotSpot(TM) 64-Bit Server VM (23.25-b01 mixed mode windows-amd64 compressed oops)
>  # Problematic frame:
>  # C  [ntdll.dll+0x53290]  RtlFreeHeap+0xd0
> 
> The root cause is that the libvirt DLL uses MSVCRT as its runtime
> library, whereas the jnidispatch DLL of JNA uses a different one.
> 
> At runtime, when calling org.sun.com.jna.Native.free() the OS function
> RtlFreeHeap is called with an invalid Pointer that was actually
> allocated by MSVCRT's malloc.
> 
> Basically, we cannot simply mix and match memory allocation functions
> from different runtime libraries, but have to call virFree for
> pointers orignating from libvirt itself.
> 
> So, this patch re-adds and uses the virFree method which had been
> removed in commit 3220de292990bed71828fba2f3700bc846d440f2.
> 
> Signed-off-by: Claudio Bley <cbley@xxxxxxxxxx>
> ---
>  src/main/java/org/libvirt/Library.java     |    4 ++--
>  src/main/java/org/libvirt/jna/Libvirt.java |    2 ++
>  2 files changed, 4 insertions(+), 2 deletions(-)

NACK to this.

virFree is an internal only symbol which is not guaranteeed to be
ABI stable across libvirt releases. ie we may remove or rename it
or change its API signature at any time. 

Not sure what else to suggest though.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]