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

fix: mismatch method signature of libc's calloc #201

Merged
merged 2 commits into from
May 14, 2024

Conversation

johntaiko
Copy link
Contributor

@johntaiko johntaiko commented May 14, 2024

https://docs.rs/libc/latest/libc/fn.calloc.html

pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;

@johntaiko johntaiko linked an issue May 14, 2024 that may be closed by this pull request
1 task
@johntaiko johntaiko requested a review from Brechtpd May 14, 2024 05:22
@Brechtpd
Copy link
Contributor

Wooooooow gonna try it out!

@smtmfft
Copy link
Contributor

smtmfft commented May 14, 2024

Just wondering why mismatched declaration does not lead to link failure

@johntaiko
Copy link
Contributor Author

johntaiko commented May 14, 2024

Just wondering why mismatched declaration does not lead to link failure

Linker is only a sysmbol(function name) lookup table without any syntax check, and it supports variable-counts arguments, the caller and the callee need to strictly adhere to the constraints themselves.

https://www.reddit.com/r/rust/comments/xl9ths/comment/ipixn53/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

@smtmfft
Copy link
Contributor

smtmfft commented May 14, 2024

Just wondering why mismatched declaration does not lead to link failure

Linker is only a sysmbol(function name) lookup table without any syntax check, and it supports variable-counts arguments, the caller and the callee need to strictly adhere to the constraints themselves.

https://www.reddit.com/r/rust/comments/xl9ths/comment/ipixn53/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

Oh, it seems a 2 levels include reference, so here rust extern C ABI conceals the real signature in libc.h.

Copy link
Contributor

@Brechtpd Brechtpd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was a bit afraid when I first saw SP1 still not working, but it seems making the function public did the trick!

@johntaiko johntaiko merged commit ecde21d into main May 14, 2024
11 checks passed
@johntaiko johntaiko deleted the fix/c-kzg-panic-in-zkvm branch May 14, 2024 11:12
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

Successfully merging this pull request may close these issues.

c-kzg failing in SP1 due to unaligned access
3 participants