COMPILED_MAGIC_SUFFIX check from memcmp equals 0 -> arrayPtr equality
This change follows the pattern of other safety changes to use ArrayPtr equality rather than memcmp == 0, which has bounds checking.
This PR also adds a test that compiled binaries run correctly using sh_test.
What's the rationale for this change? Is it better memory safety?
The rationale is that ArrayPtr does bounds checking on the pointers that are passed into it.
Also how did you test this? Do we have any tests for this code path in CI?
This is tested by anything that calls into the cli main, I basically tried combinations that I thought would be wrong and most cases caused about 70 tests to fail. Happy to send any info you would like to see before merging this. I'm also happy to find out how to write an explicit test to make sure this behavior is correct.
I suspect there is not an explicit test for this functionality. The thing you need to test is using the workerd compile command to create a self-contained binary, then run that binary.
(Yes, it's possible to make other tests fail by making the comparison succeed spuriously, since that will engage the self-contained binary mode when it's not intended.)
Does this mean that we want to create a new test for this?
It would be nice to have a test, yes. You could test this using a shell test pretty easily, I think.