<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: "Times New Roman", Times, serif, Times, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p>Dear all,</p>
<p><br>
</p>
<p>I have a simple demo code attached below, which gives a <span>segmentation violation error.</span></p>
<p><span>Can you help me with this problem? I think the problem is due to the destroy function.</span></p>
<p><span>I am using version 3.19.2 with debugging.</span></p>
<p><span><br>
</span></p>
<p><span></span></p>
<div>
<div>#include <petsc.h></div>
<div><br>
</div>
<div>static char help[] = "test.\n";</div>
<div>int main(int argc, char *argv[]) {</div>
<div> PetscCall(PetscInitialize(&argc, &argv, 0, help));</div>
<div> PetscScalar *nodes;</div>
<div> PetscScalar *weights;</div>
<div> PetscScalar **diff;</div>
<div> PetscInt n = 3;</div>
<div> PetscCall(PetscMalloc2(n, &nodes, n, &weights));</div>
<div> PetscCall(PetscDTGaussLobattoLegendreQuadrature(n, PETSCGAUSSLOBATTOLEGENDRE_VIA_LINEAR_ALGEBRA, nodes, weights));</div>
<div> PetscCall(PetscGaussLobattoLegendreElementGradientCreate(n, nodes, weights, &diff, NULL));</div>
<div> PetscCall(PetscGaussLobattoLegendreElementGradientDestroy(n, nodes, weights, &diff, NULL));</div>
<div> PetscCall(PetscFree2(nodes, weights));</div>
<div> PetscCall(PetscFinalize());</div>
<div> return 0;</div>
<div>}</div>
<br>
</div>
<p></p>
<p><br>
</p>
<p>Junming</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,Times,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p style="font-family:Calibri,Helvetica,sans-serif; font-size:16px"><span style="font-family:"Times New Roman",Times,serif; font-size:12pt"></span></p>
</div>
</div>
</div>
</body>
</html>