我正在使用gSoap编写Web服务客户端并使用Valgrind检查内存问题。
Valgrind报告没有泄漏,但显示了这个奇怪的(至少对我而言)内存错误消息:
==3529== Conditional jump or move depends on uninitialised value(s)
==3529== at 0x405D6DC: soap_reference (stdsoap2.c:6926)
==3529== by 0x405305D: soap_serialize_string (sepomexC.c:4982)
==3529== by 0x404AF5E: soap_serialize_ns1__asentamientosPorCodigoPostalRqType (sepomexC.c:2629)
==3529== by 0x40500F3: soap_serialize_PointerTons1__asentamientosPorCodigoPostalRqType (sepomexC.c:4103)
==3529== by 0x4046666: soap_serialize___sep__consultarAsentamientosPorCodigoPostal (sepomexC.c:1233)
==3529== by 0x4053A7D: soap_call___sep__consultarAsentamientosPorCodigoPostal (sepomexClient.c:186)
==3529== by 0x40417CA: consultarAsentamientosPorCodigoPostal (main.c:73)
==3529== by 0x804870C: main (sepomexmain.c:31)
==3529==
==3529== Conditional jump or move depends on uninitialised value(s)
==3529== at 0x4061AA5: soap_element_id (stdsoap2.c:9583)
==3529== by 0x4068B0C: soap_outstring (stdsoap2.c:12681)
==3529== by 0x4052DAE: soap_out_xsd__integer (sepomexC.c:4918)
==3529== by 0x404B062: soap_out_ns1__asentamientosPorCodigoPostalRqType (sepomexC.c:2643)
==3529== by 0x4050179: soap_out_PointerTons1__asentamientosPorCodigoPostalRqType (sepomexC.c:4111)
==3529== by 0x4046698: soap_out___sep__consultarAsentamientosPorCodigoPostal (sepomexC.c:1238)
==3529== by 0x4046818: soap_put___sep__consultarAsentamientosPorCodigoPostal (sepomexC.c:1274)
==3529== by 0x4053AF6: soap_call___sep__consultarAsentamientosPorCodigoPostal (sepomexClient.c:193)
==3529== by 0x40417CA: consultarAsentamientosPorCodigoPostal (main.c:73)
==3529== by 0x804870C: main (sepomexmain.c:31)
==3529==
==3529== HEAP SUMMARY:
==3529== in use at exit: 0 bytes in 0 blocks
==3529== total heap usage: 160 allocs, 160 frees, 16,161 bytes allocated
==3529==
==3529== All heap blocks were freed -- no leaks are possible
==3529==
==3529== For counts of detected and suppressed errors, rerun with: -v
==3529== Use --track-origins=yes to see where uninitialised values come from
==3529== ERROR SUMMARY: 3 errors from 2 contexts (suppressed: 21 from 8)
NO LEAKS是个好消息,但这个错误是否重要?据我所知,它们是在stdsoap2.c(gSoap文件)中生成的。
感谢。
编辑:谢谢你的回答。正如你们中的一些人告诉我我有未初始化的东西,这是我的请求结构变量。我这样解决了:
struct ns1__myRequestType request;
memset(&request, 0, sizeof(struct ns1__myRequestType));
现在Valgrind的输出是“干净的”:)非常感谢。
答案 0 :(得分:4)
它基本上是指根据未初始化的变量采取一些分支的事实。它们可能只是在库函数范围内本地的自动变量,它们在堆栈上分配,并且在if
,while
,switch
或其他中使用之前未分配值分支表达的形式。一般来说,这不是一件好事,因为它可能导致未定义的行为,但如果错误是库内部的,那么编写器可能正在做某种类型的假定内存叠加操作,等等。它们非正式地“初始化”而不是在标准C语法中显式初始化。另一种可能性是你也可以将指向未初始化变量的指针传递给其中一个库函数,这将是糟糕的编程形式,并可能产生不可预测的结果或安全风险。