Elementary problem: Agent++ segv under Linux

D. R. Evans N7DR____arrl.net
Mon Sep 10 23:15:09 CEST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I downloaded agent++/snmp++ over the weekend. Running under Linux Mandrake 7.2, 
the builds seemed to go fine.

However, whenever I try to any code that is based on agent++, I get a segv.

I tried a couple of the examples (under, naturally enough, "examples"). They 
build fine, although for some reason I had to use the static version of the 
libraries, since the system was unable to find the shared libraries at runtime, 
no matter where I put them. This is not a biggie, since I much prefer to use 
static libraries anyway.

The examples always crash, apparently in the calls to Mib(). [It's hard to be 
sure, because threaded programs aren't debuggable under gdb when running Linux 
Mandrake 7.2.]

I took another tack, and tried to write a near-to-trivial program that would 
simply start the agent, and then I would could try to use the supplied snmpGet 
to interrogate it.

So here is the closest-to-trivial agent that I could come up with. It should do 
nothing except sit and wait for requests. Since there is nothing in the MIB, 
then all incoming GETs should fail.

- -----

< I have removed the .h file #includes >

// SNMP globals

const int SNMP_PORT = 161;

Mib         mib;
RequestList request_list;
Snmpx*      snmp_p;

void main(void)
{ int snmp_status;
  snmp_p = new Snmpx(snmp_status, SNMP_PORT);
  if (snmp_status != SNMP_CLASS_SUCCESS)
  { cerr << "Error: unable to start SNMP agent" << endl;
    exit(0);
  }
  else
    cerr << "SNMP agent started" << endl;

  request_list.set_snmp(snmp_p);

  Request* req;
  while (1)
  { cerr << "Looping" << endl;
    req = request_list.receive(2);
    if (req)
    { cerr << "Inside non-zero req" << endl;
      mib.process_request(req);
    }
  }
}

- -----

OK. So it builds and runs. But as soon as I send it a GET from the snmpGet 
program, it does a segv. The failure appears to be in the call to receive(2), 
since I never see the "Inside non-zero req" message.

What stupid thing am I doing or failing to do??? I probably am simply not 
understanding something, even after a fair amount of time perusing the 
documentation and the examples.

  Doc Evans




- ----------------------------------------------------------
D.R. Evans N7DR / G4AMJ                      N7DR at arrl.net

A dead lawyer in a Colorado ski resort and an Australian detective 
who 
doesn't play by the rules: 
   "All Or Nothing" is now available. 
See http://www.sff.net/people/N7DR/drevans.htp for details.
- ----------------------------------------------------------


-----BEGIN PGP SIGNATURE-----
Version: PGP 6.0.2 -- QDPGP 2.60 
Comment: Key obtainable from servers: ID 0x362912B8

iQA/AwUBO50tX2nXrLw2KRK4EQKsyQCfU822YYomqN51lSh5FjysvJ59I9oAn2y0
WG8zyl2fLamCpWf7XiQY85tI
=Esm+
-----END PGP SIGNATURE-----



More information about the AGENTPP mailing list