Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll explain the first error to you.</p> <pre><code>==1893== Invalid read of size 4 ==1893== at 0x80498E0: delete_min (huffman.c:331) ==1893== by 0x80492DA: huffman_encode (huffman.c:196) ==1893== by 0x8049DDE: encode_file (main.c:94) ==1893== by 0x8049BBE: main (main.c:32) </code></pre> <p>At line 331, you're probably reading an (unsigned) int, in a part of the memory you haven't allocated for your own program.</p> <pre><code>==1893== Address 0x441d9a8 is 0 bytes inside a block of size 452 free'd ==1893== at 0x402BC70: realloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==1893== by 0x8049922: delete_min (huffman.c:335) ==1893== by 0x80492CC: huffman_encode (huffman.c:195) ==1893== by 0x8049DDE: encode_file (main.c:94) ==1893== by 0x8049BBE: main (main.c:32) ==1893== </code></pre> <p>This part gives more information about the part of memory you tried to read. It says you've already used the memory, but reallox freed it. That means you're reading from an old pointer to a part of memory you've realloccated.</p> <p>You should make sure you use the pointer realloc returns, and not the old one.</p> <p>The reason this doesn't crash when running outside valgrind, is that most of the time, the same part of memory will be allocated by realloc. So the pointer remains the same, and as such your code will work. However, sometimes, realloc will decide to move the part of the memory, and then your code will crash. Valgrind's trying to warn you for this.</p> <p>The rest of the errors will probably be solved when you're using the returned pointer.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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