checkObjects problem

I've been looking at trying to use libSMI in the Net-SNMP library, (replacing our current parser) and have run into a problem whereby libSMI crashes out in the middle of parsing HOST-RESOURCES-MIB.
This is in the middle of a large amount of Net-SNMP code, and a noddy test program that does "exactly the same things" works fine :-( The puzzling thing is that the crash is happening within the 'checkObjects' routine, and the noddy program never seems to call this at all.
I realise that I'm probably doing something dumb, and will have to track this down for myself. But I'm somewhat stuck, so am posting here in the hope that someone can point me in the right direction.
The immediate cause of the crash is the block of code headed "Determine the longest common OID prefix of all nodes" (parser-smi.y lines 472-487 of libsmi-0.2.16)
The first candidate considered for 'modulePtr->prefixNodePtr' is the node 'hrMIBAdminInfo' {1,3,6,1,2,1,25,7} - oid length 8. This is presumably picked up from the MODULE-IDENTITY assignment.
Shortly afterwards, the node 'host' is considered as a candidate for prefixNodePtr. This has OID {1,3,6,1,2,1,25} - length 7. This is indeed the appropriate choice for prefixNodePtr.
The block of code in question compares the individual subidentifiers of the current prefixNodePtr (line 479) with the equivalent subids of the new candidate (lines 480/481). In this case, the first seven subids all match, and the eighth subid of 'hrMIBAdminInfo' is compared against the (non-existant) eighth subid of 'host'. At which point the library falls over with a SEGV.
Is this a bug in the library, or my code ?
If it's a problem with the library, why doesn't the noddy program tickle it? (I can post the code of this if that would be helpful).
Is there any advice as to how I can avoid invoking 'checkObjects'? Or is that just applying a sticking plaster and leaving the real problem?
Dave
-- !! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To subscribe or !! unsubscribe, send a mail message to libsmi-request@ibr.cs.tu-bs.de. !! See http://www.ibr.cs.tu-bs.de/projects/libsmi/ for more information.

Hi!
Dave> I've been looking at trying to use libSMI in the Net-SNMP library, Dave> (replacing our current parser) and have run into a problem whereby Dave> libSMI crashes out in the middle of parsing HOST-RESOURCES-MIB.
Dave, I appreciate to hear about this, at least the first part of the sentence. ;-)
Dave> [...detailed problem description...] Dave> Is this a bug in the library, or my code ?
Dave> If it's a problem with the library, why doesn't the noddy program Dave> tickle it? (I can post the code of this if that would be helpful).
It's a bug in the library, that is hopefully fixed by the attached patch, which is also in the CVS repository.
Your second program probably just did not fail on it, because of a less determistic and more fortunate memory allocation layout. ;-)
Maybe, I should play with dmalloc again...
Dave> Is there any advice as to how I can avoid invoking Dave> 'checkObjects'? Or is that just applying a sticking plaster and Dave> leaving the real problem?
checkObjects() is called unconditionally at the `END' of each parsed module. I cannot explain why you did not see it called from your simple test program.
-frank
diff -u -r1.144 parser-smi.y --- parser-smi.y 2001/06/06 07:36:37 1.144 +++ parser-smi.y 2001/06/06 11:59:46 @@ -509,6 +509,10 @@ if (!modulePtr->prefixNodePtr) { modulePtr->prefixNodePtr = objectPtr->nodePtr; } else { + if (objectPtr->nodePtr->oidlen < modulePtr->prefixNodePtr->oidlen) + modulePtr->prefixNodePtr = + findNodeByOid(objectPtr->nodePtr->oidlen, + modulePtr->prefixNodePtr->oid); for (i = 0; i < modulePtr->prefixNodePtr->oidlen; i++) { if (modulePtr->prefixNodePtr->oid[i] != objectPtr->nodePtr->oid[i]) { -- !! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To subscribe or !! unsubscribe, send a mail message to libsmi-request@ibr.cs.tu-bs.de. !! See http://www.ibr.cs.tu-bs.de/projects/libsmi/ for more information.

Dave> I've been looking at trying to use libSMI in the Net-SNMP library, Frank> Dave, I appreciate to hear about this
Yes - I thought that might please you. See - we do sometimes listen :-)
Frank> It's a bug in the library, that is hopefully fixed by the attached Frank> patch, which is also in the CVS repository.
Yup - that seems to have fixed things. Thanks. Everything seems to be working properly now.
Dave
-- !! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To subscribe or !! unsubscribe, send a mail message to libsmi-request@ibr.cs.tu-bs.de. !! See http://www.ibr.cs.tu-bs.de/projects/libsmi/ for more information.
participants (2)
-
Dave Shield
-
Frank Strauss