Skip to content

Instrumentation hook handler functions are hardcoded for 64-bit #510

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

Open
kkysen opened this issue Jul 12, 2022 · 0 comments
Open

Instrumentation hook handler functions are hardcoded for 64-bit #510

kkysen opened this issue Jul 12, 2022 · 0 comments

Comments

@kkysen
Copy link
Contributor

kkysen commented Jul 12, 2022

The handler functions in analysis/runtime/src/handlers.rs for the hooked allocator functions are currently hardcoded for 64-bit systems, namely

malloc:

pub fn malloc(mir_loc: MirLocId, size: u64, ptr: usize) {

calloc:

pub fn calloc(mir_loc: MirLocId, nmemb: u64, size: u64, ptr: usize) {

realloc:

pub fn realloc(mir_loc: MirLocId, old_ptr: usize, size: u64, new_ptr: usize) {

reallocarray:

pub fn reallocarray(mir_loc: MirLocId, old_ptr: usize, nmemb: u64, size: u64, new_ptr: usize) {

These functions match the c2rust transpiled malloc, calloc, realloc, reallocarray on 64-bit systems, but c2rust transpile hardcodes size_t as libc::c_ulong, which (usually, not on Windows) is u64, rather than using the platform-independent libc::size_t/usize. This is something we'd like to fix in c2rust transpile (#259, #305), but at least for that you could re-transpile on different platforms. We can't do that for c2rust_analysis_rt, though, so we should match the platform-independent way libc translates these functions, using libc::size_t.

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