g++ -pthread -o test test.cpp
valgrind --tool=memcheck ./test
==11054== Memcheck, a memory error detector.
==11054== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==11054== Using LibVEX rev 1804, a library for dynamic binary translation.
==11054== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==11054== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation framework.
==11054== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==11054== For more details, rerun with: -v
==11054==
==11054== Syscall param epoll_wait(events) points to unaddressable byte(s)
==11054== at 0x40007F2: (within /lib/ld-2.7.so)
==11054== by 0x8048623: main (in /mnt/hgfs/NetFrameL/test)
==11054== Address 0x42c10bc is 0 bytes after a block of size 148 alloc'd
==11054== at 0x4023294: operator new(unsigned) (vg_replace_malloc.c:224)
==11054== by 0x8048615: main (in /mnt/hgfs/NetFrameL/test) #include <pthread.h>
#include <sys/epoll.h>
class CNetMsgImp
{
public:
struct epoll_event m_events[12];
char temp[1000];
int m_kdpfd;
CNetMsgImp();
~CNetMsgImp();
};
CNetMsgImp::CNetMsgImp()
{
m_kdpfd = epoll_create(11+11);
m_events[11].events = 11;
epoll_wait(m_kdpfd,m_events, 20, -1);
}
int main(int argc, char* argv[])
{
CNetMsgImp* netMsgImg = new CNetMsgImp;
}
復(fù)制代碼
g++ -pthread -o test test.cpp
valgrind --tool=memcheck ./test
==11092== Memcheck, a memory error detector.
==11092== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==11092== Using LibVEX rev 1804, a library for dynamic binary translation.
==11092== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==11092== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation framework.
==11092== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==11092== For more details, rerun with: -v
==11092==