Fix UBSan error: Shifting 64 bit type by 64 is undefined behaviour#53
Fix UBSan error: Shifting 64 bit type by 64 is undefined behaviour#53DanielG wants to merge 1 commit into
Conversation
Shifting a type by >=sizeof(type)*8 is undefined behaviour in C. Since t->prng.buf is overwritten on the next iteration anyways this thankfully isn't a real bug here. Fixes silentbicycle#52
|
Being able to take more than 64 bits here could be a sign of a deeper issue. Thanks for reporting this. I probably won't get to reviewing this closely for a bit because of the holidays, but when I do I'll retarget the PR for the develop branch. |
|
This just bit me too! I think the fix is correct — there's no attempt to take more than 64 bits, which you're right would be a deeper issue. It's just that if you take exactly 64 bits, then there's no need to shift anything in |
@silentbicycle have you had a chance to look at it? |
|
Not really. The general state of this project is that I started working on a multi-process version, because it benefits tremendously from using multiple CPU cores for parallel search, but along the way the codebase grew about 20x as large, I got massively burnt out on working on it, and haven't gotten back to it for several years. Changing life circumstances have given me little time for open source projects these days. I will probably eventually restart the project, but with a completely clean start and some major rethinking of the interfaces. The core library may be in Rust, since that will provide a lot of infrastructure I had to implement myself, though I want the library be usable for testing and fuzzing both C and Rust, possibly other languages with adapter libraries. (I'd probably maintain one for Lua, since those are the three languages I tend to use most these days.) |
Shifting a type by
>=sizeof(type)*8is undefined behaviour in C. Sincet->prng.bufis overwritten on the next iteration anyways this thankfullyisn't a real bug here.
Fixes #52