Skip to content

Commit

Permalink
fix: outlive 提前ended导致被回收两次的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Bylx666 committed Mar 30, 2024
1 parent 855826f commit ca138a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
10 changes: 3 additions & 7 deletions samples/helloworld.ks
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
//mod D:\code\rs\key-native\target\debug\key_native.dll> m;
//mod samples\testmod.ks> m;

let b = ||{
let a = 99;
:a
}();
let a = 233;
let c = 1919810;
log(`一彤好想你{a*20},{b} 真的假的{c}哭`)
let test() log("ok");
let o = {f:test};
(o.f)(); // ok
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ static DISTRIBUTION:&str = "Subkey";

fn main()-> ExitCode {
// 参数类型检查
// 字符串捕获变量
// str的index
// let [] = x
// let a=0,b=0
// prelude mod 让模块本身帮你初始化上下文
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/outlive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ pub fn scope_end(mut scope:Scope) {
}
}

scope.ended = true;
for Variant { v, .. } in &scope.vars {
drop_func(v);
}

// 回收作用域本身
scope.ended = true;
if scope.outlives.load(Ordering::Relaxed) == 0 {
// println!("{:02}: scope drop by end: {:p}",ln(), scope.ptr);
unsafe { std::ptr::drop_in_place(scope.ptr) }
Expand Down

0 comments on commit ca138a7

Please sign in to comment.