<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-CN" link="blue" vlink="purple" style="text-justify-trim:punctuation">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> I try to verify the JNA with concurrent situation but meet some problems. The following is my example code:<o:p></o:p></span></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> public static void testcase1() throws LibvirtException<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> Connect conn=null;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> Connect conn1=null;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"><o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> <o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> //connect to the hypervisor<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> conn = new Connect("esx://10.74.125.68:443/?no_verify=1&transport=https", new ConnectAuthDefault(), 0);<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> System.out.println(conn.getVersion());<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%">
<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> //connect to the hypervisor<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> conn1 = new Connect("esx://10.74.125.90:443/?no_verify=1&transport=https", new ConnectAuthDefault(), 0);<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> System.out.println(conn1.getVersion());<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%">
<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> <o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> while(true)<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> int[] array = new int[100000000];<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> Long version = conn.getVersion();<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> Long version1 = conn1.getVersion();<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%">
<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> try<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> Thread.sleep(1000);<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> }<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> catch(Exception e)<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> }<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> }<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%">}<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><span lang="EN-US" style="color:#0D0D0D;mso-style-textfill-fill-color:#0D0D0D;mso-style-textfill-fill-alpha:100.0%">When I add line “<i>int[] array = new int[100000000]</i>”, then the following error will be generated
very quickly:<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%"># An unexpected error has been detected by Java Runtime Environment:<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%">#<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%"># SIGSEGV (0xb) at pc=0x0000003f9b07046e, pid=30049, tid=1109510464<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%">#<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%"># Java VM: OpenJDK 64-Bit Server VM (1.6.0-b09 mixed mode linux-amd64)<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%"># Problematic frame:<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%"># C [libc.so.6+0x7046e]<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%">#<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%"># An error report file with more information is saved as:<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#A6A6A6;mso-style-textfill-fill-color:#A6A6A6;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><span lang="EN-US" style="color:black">I have tried to write the similar code as following. It works well.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%">static void virXenBasic_TC001(void)<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%">{<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> virConnectPtr conn = NULL;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> virConnectPtr conn1 = NULL;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> unsigned long version = 0;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> unsigned long version1 = 0;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> char *hostname = NULL;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> conn = virConnectOpenAuth("esx://10.74.125.21/?no_verify=1", virConnectAuthPtrDefault,
0);<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> if (conn == NULL) {<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> fprintf(stderr, "Failed to open connection to qemu:///system\n");<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> return;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> }<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> conn1 = virConnectOpenAuth("esx://192.168.119.40/?no_verify=1", virConnectAuthPtrDefault,
0);<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> if (conn1 == NULL) {<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> fprintf(stderr, "Failed to open connection to qemu:///system\n");<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> return;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> }<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> while(true)<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> {<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> hostname = malloc(sizeof(char) * 100000000);<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> virConnectGetVersion(conn, &version);<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> virConnectGetVersion(conn, &version1);<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> free(hostname);<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> sleep(1);<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> }<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"> return;<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%">}<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#7F7F7F;mso-style-textfill-fill-color:#7F7F7F;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#0D0D0D;mso-style-textfill-fill-color:#0D0D0D;mso-style-textfill-fill-alpha:100.0%">B.R.<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:21.6pt"><i><span lang="EN-US" style="color:#0D0D0D;mso-style-textfill-fill-color:#0D0D0D;mso-style-textfill-fill-alpha:100.0%">Benjamin Wang<o:p></o:p></span></i></p>
</div>
</body>
</html>