loading...

How I found a bug in the Rust compiler on day 1 of learning Rust

yujiri8 profile image Ryan Westlund ・1 min read

A few days ago I started learning Rust. It was on my first day that I encountered a compiler message telling me I'd found a bug that I should report.

What had I done? I'd run rustc ..

Of course, rustc is not meant to be used on directories, but apparently wasn't doing its own check; it was depending on the open syscall returning EISDIR. And on FreeBSD, it doesn't. FreeBSD actually lets you open a directory (I heard this will be finally fixed in 13.0).

Here's the issue. I noticed it didn't happen on all directories, so I did some experimenting and eventually figured out it happens on directories with less than 6 files, and the panic only happens if they're referred to as .. Other people are finding what causes it in the rustc source.

Of course this is more of a bug in FreeBSD than in Rust, but rustc also shouldn't panic and tell the user to report a bug because of weird bytes in the source, so now I can go around telling everyone I found a bug in Rust on my first day of learning Rust.

Discussion

pic
Editor guide