Open kosak opened 8 years ago
Thanks for this report! That isn't great, and it looks like we were unlucky enough to not end up with that being a segmentation fault. valgrind does indeed catch it though:
$ valgrind --leak-check=no ./a.out 16
==11000== Memcheck, a memory error detector
==11000== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11000== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==11000== Command: ./a.out 16
==11000==
==11000== Invalid write of size 1
==11000== at 0x4005FD: main (in /home/kamal/projects/one-second/benchmarks/a.out)
==11000== Address 0x51de050 is 0 bytes after a block of size 16 alloc'd
==11000== at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==11000== by 0x4005C7: main (in /home/kamal/projects/one-second/benchmarks/a.out)
==11000==
2==11000==
==11000== HEAP SUMMARY:
==11000== in use at exit: 16 bytes in 1 blocks
==11000== total heap usage: 1 allocs, 0 frees, 16 bytes allocated
==11000==
==11000== For a detailed leak analysis, rerun with: --leak-check=full
==11000==
==11000== For counts of detected and suppressed errors, rerun with: -v
==11000== ERROR SUMMARY: 13 errors from 1 contexts (suppressed: 0 from 0)
/cc @jvns
Yeah. Not filling every entry is not great either, since it's not really a fair comparison if you're not touching every byte.
There are a few bugs in
fill_array_out_of_order.c
I have modified your program to add printf statements and to store '5'. This is the code:
And here are some (buggy) results: