---
layout: post
author: Pascal Cuoq
date: 2011-05-31 21:34 +0200
categories: csmith rant
format: xhtml
title: "The Stupidest Question I have ever heard at a Computer Science presentation"
summary: 
---
{% raw %}
<p>Some time back, I reported a Csmith bug against the last git version. 
This is in no way a rant against <a href="http://embed.cs.utah.edu/csmith/">Csmith</a>  a fine piece of engineering. 
Csmith does something that I would not have thought possible if you had asked 
me before I saw it: it generates random C programs that are both 
free of undefined behavior and varied enough to uncover a ton 
of bugs in the C-accepting program you pipe it into.</p> 
<blockquote><p>Unless the C-accepting program is <a href="http://compcert.inria.fr/">CompCert</a>  in which case you only uncover a couple of bugs  apparently.</p> 
</blockquote> 
<p>Bugs in random programs have a funny way to find themselves. You don't need 
to try many inputs  as the random program explores these for you. 
Even if you think you are being quite the conservative user  
they pop up uninvited from time to time (although  to be fair  you can see 
that they are being fixed because they pop up less and less frequently). 
Anyway  dangling pointers were being passed as arguments to functions that didn't 
use them  although I was not using the option that allows this behavior 
in generated programs. This was my bug. It had been good company  
but I didn't feel ready for a long-term relationship. It was time to let go.</p> 
<p>Fast forward a few days  and there is this <a href="https://github.com/csmith-project/csmith/commit/208de0fc9b42dd74b0a7bf93527a3378d03fad79">promising commit</a> on github. 
I decide I may as well upgrade  although the bug was only appearing from time to 
time because I had fiddled with the parameters in a way that made it more likely to appear  
and I had not seen it at all since I had fiddled with the parameters again.</p> 
<p>Suddenly  as I re-compile  with GCC  this program generator that finds bugs 
in GCC  I am reminded of the stupidest question I ever heard at the end of 
a computer science presentation.</p> 
<p>Like many bad questions  this question was more a remark than a question. 
Adapted to the present context  it would go like this:</p> 
<blockquote><p>It doesn't make sense to use Csmith find bugs in C compilers  since it is itself compiled with a C (technically  C++) compiler.</p> 
</blockquote> 
<p>Apparently  as a physics student  much earlier  the asker had been chided for using a pendulum-based chronometer to verify the constancy of a pendulum's period.</p> 
<p>So  if I may be so bold as to impart my own wisdom to the world in the form of random remarks  there are two lessons in this post. "Be careful of circular reasoning" is one  but "software is not quite as similar to the physical world as you could expect" is another.</p>
 <p>Some time back, I reported a Csmith bug against the last git version. 
This is in no way a rant against <a href="http://embed.cs.utah.edu/csmith/">Csmith</a>  a fine piece of engineering. 
Csmith does something that I would not have thought possible if you had asked 
me before I saw it: it generates random C programs that are both 
free of undefined behavior and varied enough to uncover a ton 
of bugs in the C-accepting program you pipe it into.</p> 
<blockquote><p>Unless the C-accepting program is <a href="http://compcert.inria.fr/">CompCert</a>  in which case you only uncover a couple of bugs  apparently.</p> 
</blockquote> 
<p>Bugs in random programs have a funny way to find themselves. You don't need 
to try many inputs  as the random program explores these for you. 
Even if you think you are being quite the conservative user  
they pop up uninvited from time to time (although  to be fair  you can see 
that they are being fixed because they pop up less and less frequently). 
Anyway  dangling pointers were being passed as arguments to functions that didn't 
use them  although I was not using the option that allows this behavior 
in generated programs. This was my bug. It had been good company  
but I didn't feel ready for a long-term relationship. It was time to let go.</p> 
<p>Fast forward a few days  and there is this <a href="https://github.com/csmith-project/csmith/commit/208de0fc9b42dd74b0a7bf93527a3378d03fad79">promising commit</a> on github. 
I decide I may as well upgrade  although the bug was only appearing from time to 
time because I had fiddled with the parameters in a way that made it more likely to appear  
and I had not seen it at all since I had fiddled with the parameters again.</p> 
<p>Suddenly  as I re-compile  with GCC  this program generator that finds bugs 
in GCC  I am reminded of the stupidest question I ever heard at the end of 
a computer science presentation.</p> 
<p>Like many bad questions  this question was more a remark than a question. 
Adapted to the present context  it would go like this:</p> 
<blockquote><p>It doesn't make sense to use Csmith find bugs in C compilers  since it is itself compiled with a C (technically  C++) compiler.</p> 
</blockquote> 
<p>Apparently  as a physics student  much earlier  the asker had been chided for using a pendulum-based chronometer to verify the constancy of a pendulum's period.</p> 
<p>So  if I may be so bold as to impart my own wisdom to the world in the form of random remarks  there are two lessons in this post. "Be careful of circular reasoning" is one  but "software is not quite as similar to the physical world as you could expect" is another.</p>
{% endraw %}