Note that there are some explanatory texts on larger screens.

plurals
  1. POHow serious is the following Memory leak shown by Valgrind
    text
    copied!<p>After writing thousands of lines of code I use valgrind and am horrified to see the amount of errors. Was just using GDB before. Most of my errors are with string functions. I post a portion. I understand the error is happening because strlen does not count the trailing NULL whereas strcpy adds it. How serious is it? Do I really need to fix them? I can fix it but worry if that may lead to more errors as my code did not not keep that in mind when I as wriitng it. </p> <p>Does the strcpy copy the trailing NULL even if the is no space reserved for it?</p> <pre><code>t.write_length = (strlen("NA\n");/*Line number 116*/ t.data = malloc(strlen("NA\n");/*117*/ strcpy(t.data,"NA\n");/*118*/ </code></pre> <p>Valgrind:</p> <pre><code>==3287== Invalid write of size 1 ==3287== at 0x400764E: memcpy (mc_replace_strmem.c:497) ==3287== by 0x804A714: log_txn_commit (Log_manager.c:118) ==3287== by 0x8049D3C: on_txn_commit (TxFS_manager.c:85) ==3287== by 0x804939E: handler (Reader.c:139) ==3287== by 0xBF5F18: start_thread (in /lib/libpthread-2.12.90.so) ==3287== by 0xB37A2D: clone (in /lib/libc-2.12.90.so) ==3287== Address 0x403282b is 0 bytes after a block of size 3 alloc'd ==3287== at 0x4005BDC: malloc (vg_replace_malloc.c:195) ==3287== by 0x804A6F5: log_txn_commit (Log_manager.c:117) ==3287== by 0x8049D3C: on_txn_commit (TxFS_manager.c:85) ==3287== by 0x804939E: handler (Reader.c:139) ==3287== by 0xBF5F18: start_thread (in /lib/libpthread-2.12.90.so) ==3287== by 0xB37A2D: clone (in /lib/libc-2.12.90.so) </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