[Lustre-discuss] Finding bugs in Lustre with Coccinelle
nikitas_angelinas at xyratex.com
Sun Jan 8 01:43:00 PST 2012
Funny, I was planning to have a look at this, this weekend if time
permitted. I was interested in finding out how noticeable the issue of
false positives may be in Coccinelle, but that shouldn't be a big
problem as one will go through the generated patches manually anyway.
Its application in the Linux kernel shows that it can yield fixes for
common types of bugs, and depict cases of API misuse or where more
efficient use of APIs can be made, and as you say, I guess much more
complex things if we wanted to, so ftr I also think this could be a
useful addition to Lustre.
On Sun, 2012-01-08 at 00:58 -0700, Isaac Huang wrote:
> Today I decided to try Coccinelle on latest Lustre code found on
> master at git://git.whamcloud.com/fs/lustre-release.git.
> I came up with a simple Coccinelle script that tries to detect the
> case where a new object is allocated and dereferenced without checking
> it against NULL.
> Eight such bugs were unconvered:
> $ spatch -sp_file /tmp/LIBCFS_ALLOC.cocci -dir lnet 2>/dev/null > /tmp/lustre.diff
> $ spatch -sp_file /tmp/OBD_ALLOC.cocci -dir lustre 2>/dev/null >> /tmp/lustre.diff
> $ diffstat /tmp/lustre.diff
> b/llite/dir.c | 2 ++
> b/mdc/lproc_mdc.c | 1 +
> b/mgc/mgc_request.c | 1 +
> b/obdclass/obd_mount.c | 2 ++
> b/selftest/conctl.c | 1 +
> obdclass/obd_mount.c | 1 +
> 6 files changed, 8 insertions(+)
> I've attached here the lustre.diff, which contained dummy fixes. I
> hope they do get fixed. OBD_ALLOC.cocci is also attached.
> LIBCFS_ALLOC.cocci is almost identical - I guess they could be
> combined into one with some regex matching but I haven't figured out
> how yet.
> This is to demonstrate how useful such a tool can be. The Linux kernel
> seems to have already integrated Coccinelle checks in the build
> system. Lustre could adopt something similar, and Coccinelle could do
> much more complex things than this.
> - Isaac
> Lustre-discuss mailing list
> Lustre-discuss at lists.lustre.org
More information about the lustre-discuss