Skip to content

Core dumped where try Zval::set_string with persist trye #424

@Norbytus

Description

@Norbytus
use ext_php_rs::prelude::*;
use ext_php_rs::types::Zval;

pub fn startup(_ty: i32, _: i32) -> i32 {
    0
}

#[php_class]
#[derive(Default)]
struct Test {}

#[php_impl]
impl Test {
    #[php(constructor)]
    fn __constructor() -> Self {
        Self {}
    }
    fn test(&self) {
        let mut z = Zval::new();
        let _ = z.set_string("TEST", true);
    }
}

#[php_module]
fn module(module: ModuleBuilder) -> ModuleBuilder {
    module.class::<Test>()
}
<?php

$t = new Test;

var_dump($t->test());

Output

zend_mm_heap corrupted
[2]    41472 IOT instruction (core dumped)  php -d extension=./target/debug/libtest_php_ext.so ./index.php

OS: Archlinux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds investigationSomething is wrong, we are just not sure what/why

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions