Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building with zig and failing at runtime on mir_hash_1 #373

Closed
giann opened this issue Oct 13, 2023 · 2 comments
Closed

Building with zig and failing at runtime on mir_hash_1 #373

giann opened this issue Oct 13, 2023 · 2 comments

Comments

@giann
Copy link

giann commented Oct 13, 2023

I'm trying to build MIR with my build.zig for buzz so that users are not required to build it separately by hand and also for it to be automatically built for the current platform.

-> https://github.com/buzz-language/buzz/blob/mir/build.zig#L639-L703

It builds and links ok but crashes at runtime here:

    frame #0: 0x0000000101216270 libbuzz.dylib`mir_hash_1 [inlined] mir_get_key_part(v=<unavailable>, len=<unavailable>, relax_p=<unavailable>) at mir-hash.h:0 [opt]
   62     return state ^ mir_mum (state, p2, relax_p);
   63   }
   64  
-> 65   static inline uint64_t mir_hash_1 (const void *key, size_t len, uint64_t seed, int relax_p) {
   66     const uint8_t *v = (const uint8_t *) key;
   67     uint64_t r = seed + len;
   68 

@vnmakarov Do you have any idea as to what I might be missing?

Note that it works perfectly when building by hand with make

@giann
Copy link
Author

giann commented Jul 31, 2024

We found that the issue is that MIR seems to rely on undefined behaviour somewhere.
Building with zig ensures that any undefined behaviour results in a trace trap.
Building with -fno-sanitize=undefined which removes this behaviour, fixed it.

@giann
Copy link
Author

giann commented Jul 31, 2024

Nevermind you had -fno-sanitize=undefined in GNUMakefile I just didn't see it

@giann giann closed this as completed Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant