Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ strncpy parameters "optimized out"; overwrites random memory
    text
    copied!<p>First of all, I want to apologize for not being able to narrow down the problem enough to be able to share a short program that reproduces the bug.</p> <p>An external library (FUSE) call to <code>strncpy</code> "randomly" overwrites a <code>shared_ptr&lt;mutex&gt;</code> in my code, which causes a segfault when I try to lock that mutex. I ran my program with valgrind and it didn't catch any memory errors (valgrind flags below). When I run my code in gdb and set a watchpoint on that <code>shared_ptr</code>, it breaks on the call to strncpy. gdb says that all of <code>strncpy</code>'s parameters (dest, src, and nbytes) have been "optimized out", which makes me think it's using uninitialized memory for that call. Am I interpreting this correctly? Any idea what the cause could be?</p> <p>Here's the stack trace from gdb when the pointer is overwritten:</p> <pre><code>#0 __strncpy_ssse3 () at ../sysdeps/x86_64/multiarch/strcpy-ssse3.S:2482 #1 0x0000003245809094 in strncpy (__len=&lt;optimized out&gt;, __src=&lt;optimized out&gt;, __dest=&lt;optimized out&gt;) at /usr/include/bits/string3.h:120 #2 add_name (buf=&lt;optimized out&gt;, bufsize=&lt;optimized out&gt;, s=&lt;optimized out&gt;, name=&lt;optimized out&gt;) at fuse.c:907 #3 0x000000324580997c in try_get_path (f=&lt;optimized out&gt;, nodeid=&lt;optimized out&gt;, name=&lt;optimized out&gt;, path=&lt;optimized out&gt;, wnodep=&lt;optimized out&gt;, need_lock=&lt;optimized out&gt;) at fuse.c:956 #4 0x000000324580a281 in get_path_common (f=&lt;optimized out&gt;, nodeid=&lt;optimized out&gt;, name=&lt;optimized out&gt;, path=&lt;optimized out&gt;, wnode=&lt;optimized out&gt;) at fuse.c:1152 #5 0x0000003245812432 in fuse_lib_unlink (req=&lt;optimized out&gt;, parent=&lt;optimized out&gt;, name=&lt;optimized out&gt;) at fuse.c:1198 #6 0x0000003245817057 in fuse_ll_process_buf (data=0x6f5650, buf=0x7fffffffd850, ch=&lt;optimized out&gt;) at fuse_lowlevel.c:2441 #7 0x000000324581388f in fuse_session_loop (se=0x6f8410) at fuse_loop.c:40 #8 0x000000324580b698 in fuse_loop (f=&lt;optimized out&gt;) at fuse.c:4309 #9 0x000000324581bb8f in fuse_main_common (argc=&lt;optimized out&gt;, argv=&lt;optimized out&gt;, op=&lt;optimized out&gt;, op_size=&lt;optimized out&gt;, user_data=&lt;optimized out&gt;, compat=&lt;optimized out&gt;) at helper.c:355 #10 0x000000000046f1b6 in main (argc=4, argv=0x7fffffffdec8) at ../src/fuse.cpp:100 </code></pre> <p>Here's the arguments I ran valgrind with:</p> <pre><code>valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload