JNA Error Callback could cause core dump.

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

 



Hi,

  When I changed code as following:

public class Connect {

    // Load the native part

    static {

        Libvirt.INSTANCE.virInitialize();

        try {

            ErrorHandler.processError(Libvirt.INSTANCE);

        } catch (Exception e) {

            e.printStackTrace();

        }

       

  +     Libvirt.INSTANCE.virSetErrorFunc(null, new ErrorCallback());

}

 

The server will generate the following core dump:

Program terminated with signal 6, Aborted.

#0  0x0000003f9b030265 in raise () from /lib64/libc.so.6

(gdb) where

#0  0x0000003f9b030265 in raise () from /lib64/libc.so.6

#1  0x0000003f9b031d10 in abort () from /lib64/libc.so.6

#2  0x0000003f9b06a84b in __libc_message () from /lib64/libc.so.6

#3  0x0000003f9b07230f in _int_free () from /lib64/libc.so.6

#4  0x0000003f9b07276b in free () from /lib64/libc.so.6

#5  0x00002aaaacf46868 in ?? ()

#6  0x0000000000000000 in ?? ()

 

 

The problem was caused that when JNA call setErrorFunc, it will create ErrorCallback object. But when GC is executed, the object is GCed. But even I change code as following.

When GC is excuted, the callback object will be moved. Then C can’t find this object. Both of scenarios will cause core dump. It seems that JNA mustn’t provide ErrorCallback Class,

Because nobody can use this.

Please correct me.

 

public class Connect {

  +  private static final ErrorCallback callback = new ErrorCallback();

 

    // Load the native part

    static {

        Libvirt.INSTANCE.virInitialize();

        try {

            ErrorHandler.processError(Libvirt.INSTANCE);

        } catch (Exception e) {

            e.printStackTrace();

        }

       

  +     Libvirt.INSTANCE.virSetErrorFunc(null, callback);

}

 

 

 

B.R.

Benjamin Wang

--
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]