crash on attempt to traverse mib nodes

Hello,
I'm finding that libsmi crashes when I remove every "RFC" mib from "mibs/ietf" directory, and then execute a program which performs the following:
1. Add each directory under "mibs" to the smi path (smiSetPath).
2. Traverse each directory under "mibs", and for each mib found get the module and traverse each node in the module.
It tends to crash at attempt to traverse nodes of a mib which uses IMPORTS of an RFC- prefixed mib. Though I understand how missing dependencies could cause problems loading/traversing a mib, I'm not sure I understand why it's crashing and no error logs are present.
Thanks, Jonathan
________________________________
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.

On Thu, May 02, 2013 at 12:28:35PM +0000, Jonathan Walker wrote:
It tends to crash at attempt to traverse nodes of a mib which uses IMPORTS of an RFC- prefixed mib. Though I understand how missing dependencies could cause problems loading/traversing a mib, I'm not sure I understand why it's crashing and no error logs are present.
IMPORTS are important for properly loading a MIB module. If some IMPORTS are absent, you may end with incomplete data structures.
/js

Thanks for the response. I had assumed it was an issue with something along those lines, though I was surprised to see it results in undefined behavior instead of return of a NULL ptr (or similar). Also I was surprised to see no logs during loading of the "problematic", as it was much more difficult to pinpoint the exact location of the crash since the actual loading was successful. No troubles, just figured I'd point it out and see if there is motivation behind the lack of error handling?
-----Original Message----- From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de] Sent: Thursday, May 02, 2013 7:55 AM To: Jonathan Walker Cc: libsmi@ibr.cs.tu-bs.de Subject: Re: [libsmi] crash on attempt to traverse mib nodes
On Thu, May 02, 2013 at 12:28:35PM +0000, Jonathan Walker wrote:
It tends to crash at attempt to traverse nodes of a mib which uses IMPORTS of an RFC- prefixed mib. Though I understand how missing dependencies could cause problems loading/traversing a mib, I'm not sure I understand why it's crashing and no error logs are present.
IMPORTS are important for properly loading a MIB module. If some IMPORTS are absent, you may end with incomplete data structures.
/js
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/
________________________________
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.

Jonathan,
since it remains unclear what exactly you are doing, there is no way to provide any more concrete feedback.
/js
On Thu, May 02, 2013 at 01:11:26PM +0000, Jonathan Walker wrote:
Thanks for the response. I had assumed it was an issue with something along those lines, though I was surprised to see it results in undefined behavior instead of return of a NULL ptr (or similar). Also I was surprised to see no logs during loading of the "problematic", as it was much more difficult to pinpoint the exact location of the crash since the actual loading was successful. No troubles, just figured I'd point it out and see if there is motivation behind the lack of error handling?
-----Original Message----- From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de] Sent: Thursday, May 02, 2013 7:55 AM To: Jonathan Walker Cc: libsmi@ibr.cs.tu-bs.de Subject: Re: [libsmi] crash on attempt to traverse mib nodes
On Thu, May 02, 2013 at 12:28:35PM +0000, Jonathan Walker wrote:
It tends to crash at attempt to traverse nodes of a mib which uses IMPORTS of an RFC- prefixed mib. Though I understand how missing dependencies could cause problems loading/traversing a mib, I'm not sure I understand why it's crashing and no error logs are present.
IMPORTS are important for properly loading a MIB module. If some IMPORTS are absent, you may end with incomplete data structures.
/js
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.
!! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to libsmi-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/libsmi.

Attached is a program I am seeing problems with (uses boost for filesystem-related tasks). Put "mibs" directory under same directory as executable, and remove all "RFC-" prefixed mibs from ietf directory. The program crashes on my machine at PPP-LCP-MIB. I would expect it to have returned a NULL-ptr with a log message on call of smiGetModule(), however it returns a valid pointer and then crashes on subsequent call to smiGetFirstNode().
Library: - version 0.4.8 - built with MSVC10 - links dynamically to CRT
Application: - built with MSVC10 - links statically to libsmi - links dynamically to CRT
-----Original Message----- From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de] Sent: Thursday, May 02, 2013 8:21 AM To: Jonathan Walker Cc: libsmi@ibr.cs.tu-bs.de Subject: Re: [libsmi] crash on attempt to traverse mib nodes
Jonathan,
since it remains unclear what exactly you are doing, there is no way to provide any more concrete feedback.
/js
On Thu, May 02, 2013 at 01:11:26PM +0000, Jonathan Walker wrote:
Thanks for the response. I had assumed it was an issue with something along those lines, though I was surprised to see it results in undefined behavior instead of return of a NULL ptr (or similar). Also I was surprised to see no logs during loading of the "problematic", as it was much more difficult to pinpoint the exact location of the crash since the actual loading was successful. No troubles, just figured I'd point it out and see if there is motivation behind the lack of error handling?
-----Original Message----- From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de] Sent: Thursday, May 02, 2013 7:55 AM To: Jonathan Walker Cc: libsmi@ibr.cs.tu-bs.de Subject: Re: [libsmi] crash on attempt to traverse mib nodes
On Thu, May 02, 2013 at 12:28:35PM +0000, Jonathan Walker wrote:
It tends to crash at attempt to traverse nodes of a mib which uses IMPORTS of an RFC- prefixed mib. Though I understand how missing dependencies could cause problems loading/traversing a mib, I'm not sure I understand why it's crashing and no error logs are present.
IMPORTS are important for properly loading a MIB module. If some IMPORTS are absent, you may end with incomplete data structures.
/js
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.
!! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to libsmi-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/libsmi.
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/
________________________________
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.

Hi,
I can't reproduce this with the current head version on my mac.
/js
On Thu, May 02, 2013 at 01:44:50PM +0000, Jonathan Walker wrote:
Attached is a program I am seeing problems with (uses boost for filesystem-related tasks). Put "mibs" directory under same directory as executable, and remove all "RFC-" prefixed mibs from ietf directory. The program crashes on my machine at PPP-LCP-MIB. I would expect it to have returned a NULL-ptr with a log message on call of smiGetModule(), however it returns a valid pointer and then crashes on subsequent call to smiGetFirstNode().
Library:
- version 0.4.8
- built with MSVC10
- links dynamically to CRT
Application:
- built with MSVC10
- links statically to libsmi
- links dynamically to CRT
-----Original Message----- From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de] Sent: Thursday, May 02, 2013 8:21 AM To: Jonathan Walker Cc: libsmi@ibr.cs.tu-bs.de Subject: Re: [libsmi] crash on attempt to traverse mib nodes
Jonathan,
since it remains unclear what exactly you are doing, there is no way to provide any more concrete feedback.
/js
On Thu, May 02, 2013 at 01:11:26PM +0000, Jonathan Walker wrote:
Thanks for the response. I had assumed it was an issue with something along those lines, though I was surprised to see it results in undefined behavior instead of return of a NULL ptr (or similar). Also I was surprised to see no logs during loading of the "problematic", as it was much more difficult to pinpoint the exact location of the crash since the actual loading was successful. No troubles, just figured I'd point it out and see if there is motivation behind the lack of error handling?
-----Original Message----- From: Juergen Schoenwaelder [mailto:j.schoenwaelder@jacobs-university.de] Sent: Thursday, May 02, 2013 7:55 AM To: Jonathan Walker Cc: libsmi@ibr.cs.tu-bs.de Subject: Re: [libsmi] crash on attempt to traverse mib nodes
On Thu, May 02, 2013 at 12:28:35PM +0000, Jonathan Walker wrote:
It tends to crash at attempt to traverse nodes of a mib which uses IMPORTS of an RFC- prefixed mib. Though I understand how missing dependencies could cause problems loading/traversing a mib, I'm not sure I understand why it's crashing and no error logs are present.
IMPORTS are important for properly loading a MIB module. If some IMPORTS are absent, you may end with incomplete data structures.
/js
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.
!! This message is brought to you via the `libsmi' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to libsmi-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/libsmi.
-- Juergen Schoenwaelder Jacobs University Bremen gGmbH Phone: +49 421 200 3587 Campus Ring 1, 28759 Bremen, Germany Fax: +49 421 200 3103 http://www.jacobs-university.de/
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.
#include <smi/smi.h> #include <boost/filesystem.hpp> #include <string> #include <vector> #include <cstdio>
namespace bfs = boost::filesystem;
void traverse(const bfs::path &p, std::vectorbfs::path &parents, std::vectorbfs::path &children) { bfs::directory_iterator it(p); bfs::directory_iterator end;
for(; it != end; ++it) { const bfs::path &ch = it->path(); if(bfs::is_directory(ch)) { parents.push_back(ch); traverse(ch, parents, children); } else children.push_back(ch); }
}
int main(int argc, char* argv[]) { bfs::path mibpath(bfs::path(argv[0]).parent_path()/="mibs");
smiInit(0); std::vector<bfs::path> parents; std::vector<bfs::path> children; traverse(mibpath, parents, children); std::string smipath(mibpath.string()); for(int i=0; i<parents.size(); ++i) (smipath += ";") += parents[i].string(); smiSetPath(smipath.c_str()); for(int i=0; i<children.size(); ++i) { std::string mibname = children[i].stem().string(); SmiModule *module = smiGetModule(mibname.c_str()); if(!module) continue; printf("Got %s\n", mibname.c_str()); SmiNode *node = smiGetFirstNode(module, SMI_NODEKIND_ANY); } smiExit();
return 0; }
participants (2)
-
Jonathan Walker
-
Juergen Schoenwaelder