简体   繁体   English

gsoap / valgrind; 没有泄漏,但内存错误

[英]gsoap/valgrind; NO leaks but memory errors

I'm writting a web service client with gSoap and using Valgrind to check for memory issues. 我正在用gSoap编写一个Web服务客户端,并使用Valgrind检查内存问题。

Valgrind reports NO LEAKS but shows this strange (at least for me) memory error messages: 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)

The NO LEAKS are good news but, are this errors important? 无泄漏是个好消息,但是,此错误重要吗? As I understand they are generated in stdsoap2.c (a gSoap file). 据我了解,它们是在stdsoap2.c(一个gSoap文件)中生成的。

Thanks. 谢谢。

EDIT: Thanks for your answers. 编辑:感谢您的答复。 As some of you told me I had uninitialized stuff, it was my request struct variable. 正如你们中的一些人告诉我的那样,我有未初始化的东西,这是我的请求结构变量。 I fixed it this way: 我以这种方式修复了它:

struct ns1__myRequestType request;
memset(&request, 0, sizeof(struct ns1__myRequestType));

Now Valgrind's output is "clean" :) thanks a lot. 现在,Valgrind的输出是“干净的” :)非常感谢。

It basically refers to the fact there are some branches being taken based on variables that are uninitialized. 它基本上是指基于未初始化的变量存在一些分支的事实。 They could simply be automatic variables local in scope to the library function that are allocated on the stack and were not assigned values before they were used in a if , while , switch , or other form of branching expression. 它们可以只是在库函数作用域内局部的自动变量,这些变量在ifwhileswitch或其他形式的分支表达式中使用之前在堆栈上分配并且没有分配值。 Generally speaking this isn't a good thing to-do as it could result in undefined behavior, but if the error is internal to the library, the writers could be doing some type of assumed memory overlay operation, etc. with the variables that makes them informally "initialized" rather than explicitly initialized in standard C syntax. 一般来说,这样做不是一件好事,因为它可能导致未定义的行为,但是如果错误是库内部的,那么编写者可能会使用使它们非正式地“初始化”,而不是用标准C语法显式初始化。 Another possibility is you could have also passed pointers to uninitialized variables to one of the library functions, which would be poor programming form and possibly create unpredictable results or security risks. 另一种可能性是,您还可能将指向未初始化变量的指针传递给库函数之一,这可能是不良的编程形式,并可能产生不可预测的结果或安全风险。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM