Skip to content

memory corruption #282

@peter7891

Description

@peter7891

I tried using this in my VM.
I used this example and got memory corruption.

extern crate bdwgc_alloc;

use bdwgc_alloc::Allocator;
use std::alloc::Layout;

#[global_allocator]
static GLOBAL_ALLOCATOR: Allocator = Allocator;

fn main() {
    unsafe { Allocator::initialize() }

    loop {
        unsafe { std::alloc::alloc(Layout::from_size_align(2 ^ 8, 8).unwrap()) };
    }
}

Weird things started happening like printing string literals lead to stuff like

`�����`�����`p�`�`P�@�`0� �`��`����`����`����`����`p�`�`P�@�`0� �`��`����`p�`�`P�@�`0� �`��`����`����`����`����`p�`�`P�@�`0� �`��`����`����`����`����`p�`�`P�@�`0� �`��`����`����`����`����`p�`�`P�@�`0� �`��`����`����`����`����`p�`�`P�@�`0� �`��`����`����`����`����`p�`�`P�p�`p��p� q��q��q�@r��r�s�`s��s� t��t��t�@u��u�v�`v��v� w��w��w�@x��x�y�`y��y� z��z��z�@{��{�|�`|��|�@�`0� �`��`����`����`����`��thread 'main' panicked at 'failed printing to stdout: Bad address (os error 14)', library/std/src/io/stdio.rs:1019:9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions