
Hi,
This has come up before [1] but I'm not entirley convinced that libsmi is 64 bit clean. I've been using OpenNMS's mib2opennms[2] which uses libsmi and it fails badly on my 64 bit platform but works fine on a 32 bit one.
The failure is basically a failure to validate the MIB ( (smiModule->conformance) && (smiModule->conformance < 3 ) followed by a core dump in libsmi. Running with valgrind shows:
==30684== Invalid read of size 8 ==30684== at 0x4E3EBF3: getNextChildObject (smi.c:163) ==30684== by 0x4E40BEB: smiGetFirstNode (smi.c:1387) ==30684== by 0x4011D0: dumpXml (mib2opennms.c:102) ==30684== by 0x4019B1: main (mib2opennms.c:296) ==30684== Address 0x5434E00 is 64 bytes inside a block of size 80 free'd ==30684== at 0x4C20A6E: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==30684== by 0x4E3CDA8: smiFree (util.c:133) ==30684== by 0x4E375B9: freeNodeTree (data.c:4306) ==30684== by 0x4E385AE: loadModule (data.c:4740) ==30684== by 0x4E3F5AA: smiLoadModule (smi.c:416) ==30684== by 0x401811: main (mib2opennms.c:261) ==30684==
Which seems to indicate something has gone wrong inside libsmi. As far as I can tell the mib2opennms tool is calling the API correctly, it just seems part of the MIB tree are free'ed before use.
I've been poking around the code and the first thing that jumped out at me was:
/* misc mappings of SMI types to C types */ typedef char *SmiIdentifier; typedef unsigned long SmiUnsigned32; typedef long SmiInteger32;
Because sizeof(long) == 8 on x86_64. However I'm unsure how this would cause the breakage I'm seeing.
The "make check" target fails two tests (smidump-sming.test & smidump-cm.test) but the previous thread [1] seemed to imply these where out dated tests. Any suggestions on how I could proceed debuging would be appreciated.
[1] http://mail.ibr.cs.tu-bs.de/pipermail/libsmi/2006-March/000836.html [2]https://opennms.svn.sourceforge.net/svnroot/opennms/mib2opennms/trunk/