Add boundscheck in speccache_eq to avoid OOB access due to data race (#54840)
Like https://github.com/JuliaLang/julia/pull/54671, but for
`speccache_eq`.
Saw another segfault with this in the stack trace, hence this fix. I
also looked for other uses of `jl_smallintset_lookup` and there's one in
`idset.c`. That doesn't appear to be racy but I'm not familiar with the
code, so maybe you can take a look at it in case we need to push a fix
for that one too @gbaraldi or @vtjnash?