Created
March 13, 2025 11:51
-
-
Save wader/b29144b9ce191913028d53cc39faade3 to your computer and use it in GitHub Desktop.
alpine rust local key crash (failed reproduction)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker build --platform linux/amd64 --progress=plain . | |
FROM alpine:3.21.0 | |
RUN apk add --no-cache \ | |
coreutils \ | |
rust cargo cargo-c \ | |
bash \ | |
build-base | |
COPY test.rs . | |
COPY test.c . | |
RUN rustc -C target-feature=+crt-static --crate-type=staticlib test.rs | |
RUN gcc -O3 -static-libgcc -fno-strict-overflow -fstack-protector-all -fPIC -c test.c | |
RUN gcc -Wl,-z,relro,-z,now -o test test.o -L . -ltest -fPIE -static-pie | |
RUN file test | |
RUN ./test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <inttypes.h> | |
uint64_t random_state(uint64_t value); | |
int main() | |
{ | |
uint64_t r = random_state(123); | |
printf("r=%" PRIu64 "\n", r); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::hash::{BuildHasher, RandomState}; | |
#[unsafe(no_mangle)] | |
pub extern "C" fn random_state(value: u64) -> u64 { | |
RandomState::new().hash_one(value) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment