galloc icon indicating copy to clipboard operation
galloc copied to clipboard

good_memory_allocator::Allocator unusable in a static variable

Open Shinribo opened this issue 2 years ago • 0 comments

#![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>

Shinribo avatar Feb 13 '24 18:02 Shinribo