commit 928666ad009c70ce52cfcda71ff222f9b148b86c Author: Alberto Bertogli Date: Tue Oct 23 09:03:00 2018 +0100 libfiu 0.97 commit 45149a80b0efd33f6e822d40630e711d0193028a Author: Alberto Bertogli Date: Mon Oct 1 09:16:52 2018 +0100 preload/posix: Remove unnecessary "if (stream == NULL)" checks They're a leftover from previous code. Thanks to Ian Blanes for the suggestion! commit fc8ccf3741bb61527a02f4acfe251ae6b9cd548e Author: Alberto Bertogli Date: Mon Oct 1 09:14:53 2018 +0100 preload/posix: Don't rely on %p showing a hexadecimal representation %p is implementation defined, use PRIxPTR (from ) which should work across all platforms. Thanks to Ian Blanes for the suggestion! commit f80ba9f4dfdf9d8a6ee5d724a8aa3f7c4c107fbc Author: Alberto Bertogli Date: Sun Sep 30 21:25:59 2018 +0100 preload/posix: Simplify ferror() and clearerr() wrappers The ferror() and clearerr() wrappers are currently explicitly written, but can be condensed significantly using the existing macros. commit 4df0f02c687725a8bebf896c4b60d9596c9cfd7a Author: Alberto Bertogli Date: Sun Sep 30 22:37:05 2018 +0100 tests: Add test for the handling of FILE * errors The handling of FILE * errors is tricky, as we keep track of the streams with errors internally. This patch adds a test that exercises some of the cases related to error handling. It is not overly tricky, but it covers quite a few corner cases and already detected a couple of problems (fixed in previous patches). commit 20cd73583b0d807813720b74a2d53db88821db8f Author: Alberto Bertogli Date: Sun Sep 30 22:44:29 2018 +0100 libfiu: Improve/fix handling of deleted elements in the hash table There are a few problems with the current way deleted items are handled in the hash table, including: - We can reuse them during hash_set(), which can lead to bugs such as double and/or phantom entries. - The resizing logic is suboptimal because the removed elements are counted as valid entries (this causes unnecessary grows and shrinks, but it's otherwise harmless). - Possible infinite loops when deleting entries. Note the tests in later patches trigger most of these conditions. This patch fixes those found bugs by: - Never reusing removed entries. - Improving resize logic to consider removed entries separately. - Avoid potential infinite loops by adding iteration logic (for defense in depth). commit ad14b3c9635f851a12254f7808b6f2182ee41a31 Author: Alberto Bertogli Date: Sun Sep 30 22:38:47 2018 +0100 preload/posix: Decrement recursion counter in ferror() wrapper The ferror() wrapper is not implemented fully via the macros, and it has a bug where, under some conditions, the internal recursion counter would not be decreased, causing the library to never fail anything after it. This patch fixes the bug by adjusting the logic to always decrease the recursion counter. commit 1f41f72b59f43889afe70717976e6aabf4ff5524 Author: Alberto Bertogli Date: Sun Sep 30 21:03:27 2018 +0100 preload/posix: Replace open-coded hash table with the existing one In preload/posix/modules/posix.custom.c we need to keep a set of FILE *. Current implementation open-codes a hash table of fixed size. This patch replaces that with an existing hash table implementation. The existing one is dynamic in size, but requires to convert the pointers to string keys, so it has a performance penalty. This change is mostly to make the code easier to maintain, as ~halves the lines of code, and reuses a more tested hash implementation. commit 2b53d12fdbc3966920de72b53963b1b40496c4f3 Author: Ian Blanes Date: Sun Sep 30 11:39:25 2018 +0200 preload/posix/modules: Fix stale faked ferror entries. This patch fixes a defect where faked errors for ferror() were not properly cleared. Hash table was not properly cleared and entries were not removed during fclose(). commit 0d4f662733045f0e3f6e2936e94518cd4186129e Author: Alberto Bertogli Date: Sat Sep 29 22:50:22 2018 +0100 bindings/python: Write fiu_ctrl.py atomically When doing a parallel build, we might run both python2 and python3 builds concurrently, causing a race in writing fiu_ctrl.py. The race could result in installing a partially-written fiu_ctrl.py. This patch fixes the race by doing an atomic "write to tmp + rename" to generate fiu_ctrl.py. This bug was reported by Adrian Bunk , and found by the Debian reproducible builds project: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=909843 commit 540515f78b6b05948f9b86be51e2639b505deca0 Author: Alberto Bertogli Date: Sat Sep 29 19:33:22 2018 +0100 Makefile: Extend "clean" targets to cover more build artifacts We were leaving some build artifacts behind when we do a "make clean", this patch fixes this by adding the necessary rules. commit ddf8acdc975c4363eb821ed043541e688b11640a Author: Alberto Bertogli Date: Wed Sep 26 21:11:07 2018 +0100 preload/posix: Remove unnecessary parameter in mkwrap_def commit 88bec5780f87c8d26e9f0b68f243fe3517891064 Author: Alberto Bertogli Date: Wed Sep 26 21:07:21 2018 +0100 preload/posix: Use macros to generate wrappers for variadic functions To wrap some of the variadic functions like fprintf(), we can rely on a non-variadic counterpart like vprintf(). Today this is implemented by open-coding the wrapper, causing a significant amount of duplication (because they're all very similar to each other, and they're all very similar to the codegen.h macros). To reduce that duplication, this patch adds some specific macros to generate these variadic wrappers. commit 94e897a77605a66b4ed97cc44fc618ec10543b66 Author: Alberto Bertogli Date: Wed Sep 26 20:14:37 2018 +0100 tests: Add tests for some of the new stdio functions This patch adds tests for some of the new stdio functions (fopen(), fread(), and fprintf()). They're implemented using the test auto-generation infrastructure. commit 3481b5cce4827ea774ea86e572967274c97e9705 Author: Alberto Bertogli Date: Wed Sep 26 19:44:46 2018 +0100 libfiu: Fix strncpy() calls, make sure buffers are zero-initialized strncpy() might not copy the final \0 when the buffer is larger than the given size, so in this patch we change the calls to copy up to n-1, and make sure the destination is zero-initialized, to prevent accidental overruns. commit e0fe797d497579880864e724857ae94a478633d9 Author: Ian Blanes Date: Wed Sep 12 12:12:13 2018 +0200 Support for the full set of I/O operations in stdio.h, including proper support for stream error indicators reported by ferror() after a simulated fault. commit 0b0ab9a723d86ee17c1922709267d6f86c18df6f Author: Alberto Bertogli Date: Sat Sep 8 19:16:04 2018 +0100 gitignore: Ignore "hidden" files (.*) This is just for convenience, to have tree-local files that don't appear in "git status" by default. commit 633bd2ae5d89850fecf71161bc74f21c04904c5b Author: Alberto Bertogli Date: Sat Jun 30 20:29:00 2018 +0100 preload/posix: Make build more robust against --as-needed When building using LDFLAGS=--as-needed (as done by some distributions), the libc soname detection currently fails because gcc will not link our dummy library against libc because it's not needed, despite it appearing on the command line. To fix this, we make our dummy library (which before was actually /dev/null) use a function from libc. This was reported in Debian bug #902363 and a (different) patch was provided by Matthias Klose : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902363 commit 059ca8b35895bbc63de1cb765a4c3d4671bf60d3 Author: Alberto Bertogli Date: Mon May 21 12:30:45 2018 +0100 Allow users to set the PRNG seed via the environment To simplify the set of PRNG seeds, this patch makes fiu_init() get the seed from the FIU_PRNG_SEED environment variable, if present. This makes it easier for automated tests to control the seed without needing to instrument the code. commit 780aa563571b8d974ec740d019a91b5057cdf18e Author: Alberto Bertogli Date: Sun May 13 15:48:42 2018 +0100 Add a function to manually set the PRNG seed (fiu_set_prng_seed()) When doing randomized tests, it can be useful to have a way of reliably reproducing failures. Currently this is not possible, because the PRNG seed is set internally based on time, and users have no control over it. So this patch introduces a new function, fiu_set_prng_seed(), to allow users to manually control the PRNG seed. commit 527317f4a90045c061cada3adb40417efd489aa4 Author: Alberto Bertogli Date: Wed Apr 4 09:25:56 2018 +0100 preload/posix: Make function_list generation reproducible The make rules for function_list generation have races, which may cause the generator to be run twice, adding some duplication to the final function list. This was detected by Debian's reproducible builds automation, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=894776. This patch fixes the rule by adding the correct dependency (the .c and .fl files get generated at the same time), which makes the parallel build reproducible again.