tags 580828 -unreproducible thanks Hi,
On Sat, May 15, 2010 at 09:27:34PM -0400, Bill Gunn wrote: > It crashes with any molecular geometry I have tried either imported or > drawn in ghemical. I attach two example files I have tested. I can reproduce this, albeit only on amd64 not on i386 (Debian stable both). Can somebody reproduce this on 64bit on Debian testing or unstable? 1. start ghemical 2. switch to Draw 3. Draw one carbon 4. Compute->Setup, switch to all QM 5. Compute->Energy and then it crashes: INTERATOMIC DISTANCES 0 C 1 ------------------ C 1 0.000000 Program received signal SIGSEGV, Segmentation fault. 0x00007fffeb398f73 in lm7_ini_full_xyz () from /usr/lib/libmopac7.so.1 (gdb) bt full #0 0x00007fffeb398b5b in lm7_ini_full_xyz () at libmopac7.c:124 var_i = 1190 As lm7_ini_full_xyz() is apparently not being run by run_mopac7, it cannot be reproduced by just running the generated input file. The corresponding code is: geovar_1.nvar = geokst_1.natoms * 3; for (var_i = 0;var_i < geovar_1.nvar;var_i++) { geovar_1.loc[var_i * 2 + 0] = (var_i / 3) + 1; } for (var_i = 0;var_i < geovar_1.nvar;var_i++) { geovar_1.loc[var_i * 2 + 1] = (var_i % 3) + 1; } The value of geovar_1.nvar should be 3, but it seems the second for loop in lm7_ini_full_xyz() does not terminate appropriately as geovar_1.nvar gets frobbed (on amd64, but apparently not on i386/ia32) and finally surpasses the allocated array when it reaches 1190. The attaced patch at least doesn't make ghemical segfault anymore for me (and yields the same energy as on 32bit), but I am not sure nothing else is wrong, Can somebody reproduce this on 64bit on Debian testing or unstable? either. Michael
--- ./fortran/libmopac7.c.orig 2012-10-05 00:41:05.000000000 +0200 +++ ./fortran/libmopac7.c 2012-10-05 00:41:38.000000000 +0200 @@ -103,19 +103,19 @@ void lm7_ini_full_xyz(void) { - int var_i; + int var_i, nvar; /* by default, MOPAC changes the molecule orientation, and limits the available variables. we will change it here, by writing our own variable table. THIS IS FOR XYZ MODE ONLY! */ - geovar_1.nvar = geokst_1.natoms * 3; + nvar = geokst_1.natoms * 3; - for (var_i = 0;var_i < geovar_1.nvar;var_i++) + for (var_i = 0;var_i < nvar;var_i++) { geovar_1.loc[var_i * 2 + 0] = (var_i / 3) + 1; } - for (var_i = 0;var_i < geovar_1.nvar;var_i++) + for (var_i = 0;var_i < nvar;var_i++) { geovar_1.loc[var_i * 2 + 1] = (var_i % 3) + 1; }