valgrind complaining about __mktime - is that my fault?

大憨熊 提交于 2019-12-10 16:39:35

问题


For the first time (in my new dev environment) I'm seeing valgrind complain about mktime, but I'm not sure if this is a bug in the libc library, valgrind, or my code. I'll start with the error (below) - is this enough info to explain the cause?

==3682==    at 0x38ACE9A505: __mktime_internal (in /lib64/libc-2.12.so)
==3682==    by 0x4D66F7: ???
==3682==    by 0x4D7611: ???
==3682==    by 0x4D23CD: ???
==3682==    by 0x4D175B: ???
==3682==    by 0x38ACE1ECDC: (below main) (in /lib64/libc-2.12.so)
==3682==  Uninitialised value was created by a stack allocation
==3682==    at 0x4D64BE: ???
==3682== 
==3682== Conditional jump or move depends on uninitialised value(s)
==3682==    at 0x38ACE9A505: __mktime_internal (in /lib64/libc-2.12.so)
==3682==    by 0x4D67DA: ???
==3682==    by 0x4D7611: ???
==3682==    by 0x4D23CD: ???
==3682==    by 0x4D175B: ???
==3682==    by 0x38ACE1ECDC: (below main) (in /lib64/libc-2.12.so)
==3682==  Uninitialised value was created by a stack allocation
==3682==    at 0x4D64BE: ???

回答1:


For anyone else who runs into this...

The struct was filled by strptime, which apparently doesn't fill in struct members that aren't used (dst)...but mktime doesn't like this :) so memset it to zero



来源:https://stackoverflow.com/questions/9037631/valgrind-complaining-about-mktime-is-that-my-fault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!