OK. I tried to do some more tricks and got new signs of crash. I edited the Makefile in the folder that trace_driven.cc is compiled and instead of using -O3, I used -O1 and now I get free(): double free detected in tcache 2 At the same like that I received segfault with -O3. (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007ffff77de859 in __GI_abort () at abort.c:79 #2 0x00007ffff78493ee in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7973285 "%s\n") at ../sysdeps/posix/libc_fatal.c:155 #3 0x00007ffff785147c in malloc_printerr ( str=str@entry=0x7ffff79755d0 "free(): double free detected in tcache 2") at malloc.c:5347 #4 0x00007ffff78530ed in _int_free (av=0x7ffff79a4b80 <main_arena>, p=0x5555fdbbd7f0, have_lock=0) at malloc.c:4201 #5 0x0000555555562a88 in __gnu_cxx::new_allocator<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*>::deallocate (__p=<optimized out>, this=0x7fffffffc5a0) at /usr/include/c++/9/ext/new_allocator.h:119 #6 std::allocator_traits<std::allocator<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*> >::deallocate (__n=<optimized out>, __p=<optimized out>, __a=...) at /usr/include/c++/9/bits/alloc_traits.h:470 #7 std::_Vector_base<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*, std::allocator<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*> >::_M_deallocate (__n=<optimized out>, __p=<optimized out>, this=0x7fffffffc5a0) at /usr/include/c++/9/bits/stl_vector.h:351 #8 std::_Vector_base<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*, std::allocator<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*> >::~_Vector_base (this=0x7fffffffc5a0, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/stl_vector.h:332 #9 std::vector<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*, std::allocator<std::vector<inst_trace_t, std::allocator<inst_trace_t> >*> >::~vector (this=0x7fffffffc5a0, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/stl_vector.h:680 #10 trace_shader_core_ctx::init_traces (this=this@entry=0x55555696fb20, start_warp=0, end_warp=end_warp@entry=4, kernel=...) at trace_driven.cc:487 The code looks like std::vector<std::vector<inst_trace_t> *> threadblock_traces; for (unsigned i = start_warp; i < end_warp; ++i) { trace_shd_warp_t *m_trace_warp = static_cast<trace_shd_warp_t *>(m_warp[i]); m_trace_warp->clear(); threadblock_traces.push_back(&(m_trace_warp->warp_traces)); } trace_kernel_info_t &trace_kernel = static_cast<trace_kernel_info_t &>(kernel); printf("hello %d\n",threadblock_traces.size()); trace_kernel.get_next_threadblock_traces(threadblock_traces); Any feedback is appreciated. Regards, Mahmood On Friday, July 9, 2021, 9:57:26 AM GMT+2, Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> wrote: On Thu, 2021-07-08 at 16:42 +0000, Mahmood N via Gcc-help wrote: > Hi > > I see that my program works fine in the debug mode, but not in the > release mode. With GDB I was able to find the function that got error. > The code looks like > > > > std::vector<std::vector<inst_trace_t> *> threadblock_traces; > ... > printf("hello %d\n",threadblock_traces.size()); At least you can't use "%d" to print the result of std::vector<T>::size() (which is not an `int`). > trace_kernel.get_next_threadblock_traces(threadblock_traces); > Try to find the bug of your code with warnings, sanitizers, or -D_GLIBCXX_DEBUG. -- Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University