Bug 163266 - wishlist intentionally fail malloc operations
Summary: wishlist intentionally fail malloc operations
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-05 13:45 UTC by Kimmo Mustonen
Modified: 2013-05-06 10:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Failgrind a malloc/syscall fault injector tool (521 bytes, patch)
2012-09-20 07:41 UTC, cl.montjoie
Details
Patch for adding failgrind (29.18 KB, patch)
2013-05-06 10:01 UTC, cl.montjoie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Mustonen 2008-06-05 13:45:28 UTC
Version:            (using KDE 3.5.8)
Installed from:    00
OS:                Linux

Add an option to check for error handling correctness. It should works like this:
For every malloc(), (f)open(), (f)write(), (f)read(), etc operation, check the current stacktrace.
If this is the first time we encounter this specific stacktrace, store it in a database (for example a file given by the user)
and INTENTIONALLY return a failure for that specific operation (i.e. NULL for malloc, -1 for open(), NULL for fopen() etc).
Next the time software is run, read in the database and let the known entries operate normally, i.e. mostly succeed. This will allow one to check also leaks from the abnormal execution paths. A killer idea in my opinion!
Comment 1 cl.montjoie 2012-09-20 07:41:53 UTC
Created attachment 74044 [details]
Failgrind a malloc/syscall fault injector tool
Comment 2 cl.montjoie 2013-05-06 10:01:48 UTC
Created attachment 79727 [details]
Patch for adding failgrind

This first try is based on the none tool and I have implemented only to fail malloc, open, read, write, fopen, socket, send recv and bind functions.

Failgrind support theses options:
--failfunc for selecting which functions may fail. Example: --failfunc=malloc,open
--failclass for selecting a whole class of functions which may fail. Example --failclass=1 for failing open,read,write
--percent for choosing the percentage of function that will fail.

Example:
valgrind --tool=exp-failgrind --percent=90 --failfunc=all ls
This command will launch ls and each function call have 90% chance to fail.