c++ memory leak in queue initialization -


recently company migrated new servers , program no longer worked correctly. compiles ok, when running errors , crashes while initializing queue. using valgrind can see memory leaks in queue library. code bigger have been hard put in here, cut as thought reasonable. think there might problem can't see concerning versions or something, can suggest hints/help?

typedef  unsigned char     byte; typedef  unsigned char     boolean;  typedef  unsigned int      uint32; typedef  unsigned short    uint16; typedef  unsigned char     uint8;  typedef  signed long int   int32;       /* signed 32 bit value */ typedef  signed short      int16;       /* signed 16 bit value */ typedef  signed char       int8;        /* signed 8  bit value */ 

just type defs next part doesn't confuse

struct mipmsg {     byte           msg[1024];     uint32         msglen;     uint32         ipaddr;     ushort         sin_port;     uint32         mnhomeaddr;     struct timeval ts;     mipmsg() : msglen(0), ipaddr(0), sin_port(0) , mnhomeaddr(0)     {             memset( msg, '\0', sizeof(msg) );     } };  class mipmsgqueue { public:     mipmsgqueue();     ~mipmsgqueue();   private:     queue<mipmsg*>    mqueue_; }; 

that's h cut h file, , here's cut cpp file.

mipmsgqueue() :: mipmsgqueue() : mqueue_() { } 

and here's valgrind snippet.

==25753==    @ 0x4a0666e: operator new(unsigned long) (vg_replace_malloc.c:220) ==25753==    0x4045c6: __gnu_cxx::new_allocator<mipmsg**>::allocate(unsigned long,        void const*) (new_allocator.h:88) ==25753==    0x4045f9: std::_deque_base<mipmsg*, std::allocator<mipmsg*>    >::_m_allocate_map(unsigned long) (stl_deque.h:424) ==25753==    0x404b23: std::_deque_base<mipmsg*, std::allocator<mipmsg*> >::_m_initialize_map(unsigned long) (stl_deque.h:471) ==25753==    0x404c70: std::_deque_base<mipmsg*, std::allocator<mipmsg*> >::_deque_base(std::allocator<mipmsg*> const&, unsigned long) (stl_deque.h:368) ==25753==    0x404d0d: std::deque<mipmsg*, std::allocator<mipmsg*> >::deque(std::deque<mipmsg*, std::allocator<mipmsg*> > const&) (stl_deque.h:690) ==25753==    0x404e20: std::queue<mipmsg*, std::deque<mipmsg*, std::allocator<mipmsg*> > >::queue(std::deque<mipmsg*, std::allocator<mipmsg*> > const&) (stl_queue.h:146) ==25753==    0x4033e2: mipmsgqueue::mipmsgqueue() (mipmsgqueue.cpp:5) 

also here's gdb error code

 munmap_chunk(): invalid pointer: 0x0000000000621770 *** 

thanks reading.

using valgrind can see memory leaks in queue library

memory leaks not (usually) lead crashes. error:

munmap_chunk(): invalid pointer: 0x0000000000621770 *

implies heap corruption, possibly due calling delete on global variable. ignore memory leaks, , other valgrind errors (and invalid free/delete in particular).


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -