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

good_memory_allocator::Allocator unusable in a static variable #20

Open
Shinribo opened this issue Feb 13, 2024 · 0 comments
Open

good_memory_allocator::Allocator unusable in a static variable #20

Shinribo opened this issue Feb 13, 2024 · 0 comments

Comments

@Shinribo
Copy link

#![no_std]
#![no_main]
#![feature(allocator_api)]
pub static SPINALLOCATOR: Allocator = Allocator::empty();

This single line of code throw multiple instances of the following error: "shared static variables must have a type that implements Sync", it works perfectly if is use it as a global allocator.

Am i doing something wrong?

Detailed Errors:

*mut Option<NonNull<good_memory_allocator::chunks::FreeChunk>> cannot be shared between threads safely
within good_memory_allocator::Allocator<20, 8>, the trait Sync is not implemented for *mut Option<NonNull<good_memory_allocator::chunks::FreeChunk>>
shared static variables must have a type that implements Syncrustc

chunks.rs(750, 12): required because it appears within the type FakeFreeChunk
lib.rs(113, 12): required because it appears within the type Allocator<20, 8>

NonNull<good_memory_allocator::chunks::FreeChunk> cannot be shared between threads safely
within good_memory_allocator::Allocator<20, 8>, the trait Sync is not implemented for NonNull<good_memory_allocator::chunks::FreeChunk>
shared static variables must have a type that implements Syncrustc

option.rs(563, 10): required because it appears within the type Option<NonNull<FreeChunk>>
chunks.rs(750, 12): required because it appears within the type FakeFreeChunk
lib.rs(113, 12): required because it appears within the type Allocator<20, 8>

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