Article: Fuzzing D code with LDC

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Jan 15 10:05:06 UTC 2018


On Monday, January 15, 2018 09:49:24 Temtaime via Digitalmars-d-announce 
wrote:
> On Saturday, 13 January 2018 at 23:59:52 UTC, Johan Engelen wrote:
> > It's been a work-in-progress for half a year, but finished now:
> >
> > http://johanengelen.github.io/ldc/2018/01/14/Fuzzing-with-LDC.html
> >
> > "A not-so-well-written article about the fuzzing capability
> > recently added to LDC, using LLVM’s libFuzzer. Compiling code
> > with -fsanitize=fuzzer adds control-flow instrumentation used
> > to guide the fuzzing and links-in the libFuzzer library that
> > drives the fuzz testing (same as Clang). -fsanitize=fuzzer is
> > available from LDC 1.4.0, not on Windows. LDC 1.6.0 was used
> > for the examples in this article."
> >
> > Hope the article gives you enough information to start fuzz
> > testing your own projects.
> >
> > cheers,
> >
> >   Johan
> >
> > (per Ali's request, the article has a nice fuzzy font for some
> > of you :P)
>
> // `Throwable`s thrown are not bugs (in contrast to `Errors`).
>
> They _can_ be bugs.
> class Error : Throwable
> class Exception : Throwable

Talking about Throwables always gets a bit weird. Exceptions aren't bugs,
whereas Errors are, and we usually talk about Exceptions and Errors rather
than Throwables, and talking about Throwables implies both, but you _can_
also throw Throwables that aren't derived from Exception or Error (be it a
naked Throwable or a class derived from Throwable). You're asking for it if
you do, since there really isn't much difference between a Throwable and an
Error in terms of how the compiler and runtime deal with clean-up code and
nothrow, so trying to use a Throwable that isn't an Exception or Error can
work, but it's basically going to be treated like an Error. Really, as far
as the language and compiler are concerned, you have Exceptions, and then
you have all other Throwables. nothrow has to do with Exceptions, and
whether clean-up code is guaranteed to run or not has to do with Exceptions.
Error really doesn't come into it except that we derive from Error rather
than Throwable to more easily distinguish them from Exception. Ultimately,
Errors and other non-Exception Throwables are really treated the same.

So, all-in-all, things just get weird when you try and talk about
Throwables, and I'd generally advise against anyone trying to use any
Throwables that aren't Exceptions or Errors. Certainly, if you do, you had
better know what you're doing and be _very_ careful about it.

- Jonathan M Davis




More information about the Digitalmars-d-announce mailing list