[AGENT++] R: R: R: R: pure virtual method called

Michele Marcon M.Marcon at riello-ups.com
Mon Feb 28 11:27:35 CET 2011


Hi,
the exactly same code, when running on a simple "main()" program works correctly;
but if I run it within the library then I get this strange output.

About this patch: gethostbyname_r() returns 0.

Thanks.



Michele Marcon
Centro Ricerche
RPS SpA
Viale Europa, 7
37045 Legnago (VR)
Tel. +39 0442 635811 - Fax. +39 0442 635934 - Mobile: +39 335 1233317
Skype Id:  - VoIp:
E-mail: M.Marcon at riello-ups.com
Web: http://www.riello-ups.com
 -----------------------------------------------------------------------------------------------------
Per favore non stampare questo messaggio se proprio non è necessario
Please consider the environment before printing this e-mail
-----------------------------------------------------------------------------------------------------
Chi riceve il presente messaggio e` tenuto a verificare se lo stesso non gli sia pervenuto per errore. In tal caso e` pregato di avvisare immediatamente il mittente e, tenuto conto delle responsabilita` connesse all'indebito utilizzo e/o divulgazione del messaggio e/o delle informazioni in esso contenute, voglia cancellare l'originale e distruggere le varie copie o stampe.

The receiver of this message is required to check if he/she has received it erroneously. If so, the receiver is requested to immediately inform the sender and - in consideration of the responsibilities arising from undue use and/or disclosure of the message and/or the information contained therein - destroy the original message and any copy or printout thereof.

-----Messaggio originale-----

Da: agentpp-bounces at agentpp.org [mailto:agentpp-bounces at agentpp.org] Per conto di Jochen Katz
Inviato: martedì 22 febbraio 2011 21.21
A: agentpp at agentpp.org
Oggetto: Re: [AGENT++] R: R: R: pure virtual method called

Hi,


> I've tried the patch,
> ...
> This if evaluates to false, therefore h_addr_list is validated. However, the memcpy still crashes.

it seems that you have a strange gethostbyname function and it seems
that it is not possible to get the IP for a hostname on your system.

The patch below will check for the return values.

Regards,
  Jochen


--- address.cpp (Revision 1971)
+++ address.cpp (Arbeitskopie)
@@ -821,7 +821,14 @@
 #if defined(__sun) || defined (__QNX_NEUTRINO)
     lookupResult = gethostbyname_r(inaddr, &lookup_buf, buf, 2048,
&herrno);
 #else
-    gethostbyname_r(inaddr, &lookup_buf, buf, 2048, &lookupResult,
&herrno);
+    int tmp_ret = gethostbyname_r(inaddr, &lookup_buf, buf, 2048,
+                                 &lookupResult, &herrno);
+    if (tmp_ret)
+    {
+      debugprintf(1, "Error (%d, errno %d) from gethostbyname_r",
+                 tmp_ret, herrno);
+      lookupResult = 0;
+    }
 #endif
 #ifdef SNMP_PP_IPv6
     if (!lookupResult)
@@ -830,8 +837,14 @@
       lookupResult = gethostbyname_r(inaddr, AF_INET6, &lookup_buf,
buf, 2048,
                                      &lookupResult, &herrno);
 #else
-      gethostbyname2_r(inaddr, AF_INET6, &lookup_buf, buf, 2048,
-                        &lookupResult, &herrno);
+      int tmp_ret2 = gethostbyname2_r(inaddr, AF_INET6, &lookup_buf, buf,
+                                     2048, &lookupResult, &herrno);
+      if (tmp_ret2)
+      {
+        debugprintf(1, "Error (%d, errno %d) from gethostbyname2_r",
+                   tmp_ret2, herrno);
+        lookupResult = 0;
+      }
 #endif
     }
 #endif // SNMP_PP_IPv6
_______________________________________________
AGENTPP mailing list
AGENTPP at agentpp.org
http://lists.agentpp.org/mailman/listinfo/agentpp







More information about the AGENTPP mailing list