On Wed, Sep 05, 2012 at 08:59:07AM +0000, Benjamin Wang (gendwang) wrote:
Hi,
I try to verify the JNA with concurrent situation but meet some problems. The following
is my example code:
public static void testcase1() throws LibvirtException
{
Connect conn=null;
Connect conn1=null;
//connect to the hypervisor
conn = new
Connect("esx://10.74.125.68:443/?no_verify=1&transport=https", new
ConnectAuthDefault(), 0);
System.out.println(conn.getVersion());
//connect to the hypervisor
conn1 = new
Connect("esx://10.74.125.90:443/?no_verify=1&transport=https", new
ConnectAuthDefault(), 0);
System.out.println(conn1.getVersion());
while(true)
{
int[] array = new int[100000000];
Long version = conn.getVersion();
Long version1 = conn1.getVersion();
try
{
Thread.sleep(1000);
}
catch(Exception e)
{
}
}
}
When I add line "int[] array = new int[100000000]", then the following error
will be generated very quickly:
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000003f9b07046e, pid=30049, tid=1109510464
#
# Java VM: OpenJDK 64-Bit Server VM (1.6.0-b09 mixed mode linux-amd64)
# Problematic frame:
# C [libc.so.6+0x7046e]
#
# An error report file with more information is saved as:
I have tried to write the similar code as following. It works well.
static void virXenBasic_TC001(void)
{
virConnectPtr conn = NULL;
virConnectPtr conn1 = NULL;
unsigned long version = 0;
unsigned long version1 = 0;
char *hostname = NULL;
conn = virConnectOpenAuth("esx://10.74.125.21/?no_verify=1",
virConnectAuthPtrDefault, 0);
if (conn == NULL) {
fprintf(stderr, "Failed to open connection to qemu:///system\n");
return;
}
conn1 = virConnectOpenAuth("esx://192.168.119.40/?no_verify=1",
virConnectAuthPtrDefault, 0);
if (conn1 == NULL) {
fprintf(stderr, "Failed to open connection to qemu:///system\n");
return;
}
while(true)
{
hostname = malloc(sizeof(char) * 100000000);
virConnectGetVersion(conn, &version);
virConnectGetVersion(conn, &version1);
free(hostname);
sleep(1);
}
return;
}
Maybe you need to increase the stack or memory size of you java process or
something, that doesn't look related to libvirt at all in my opinion.
Well maybe the bindings fails somewhere at checking for an allocation
error, but is it in JNA ?
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/