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

异步调用 LiteBlock race condition (Lite stack) #9

Open
duangsuse opened this issue May 13, 2018 · 2 comments
Open

异步调用 LiteBlock race condition (Lite stack) #9

duangsuse opened this issue May 13, 2018 · 2 comments
Assignees
Labels
bug Something isn't working 我太菜了,被关了起来 垃圾 duangsuse

Comments

@duangsuse
Copy link
Collaborator

duangsuse commented May 13, 2018

Describe the bug
Lite 的本地作用域 stack 会因为异步块操作导致块所访问到的作用域错位

To Reproduce
Steps to reproduce the behavior:

race = lite.proxy Runnable, {
  run: { @a = 1; Thread.sleep(Math.random() * 10); return }
}

for _ in 0..15
  Thread(race).start()
end

while true
  if @a; break # @a should always be nil
end

Expected behavior
@A should always be nil
while should run forever

Additional context
F**king bugs

@duangsuse duangsuse added bug Something isn't working 我太菜了,被关了起来 垃圾 duangsuse labels May 13, 2018
@duangsuse duangsuse self-assigned this May 13, 2018
@duangsuse duangsuse changed the title 异步调用 LiteBlock race condition 异步调用 LiteBlock race condition (Lite stack) May 13, 2018
@duangsuse
Copy link
Collaborator Author

目前的解决方案

为异步调用的块专门准备一个本地表,不使用全局的 stack

@duangsuse
Copy link
Collaborator Author

duangsuse commented May 13, 2018

说到这里我觉得 Lite 里块都不是计算机科学里的块了,你不能这么做:

def a
  @a = "deep"
  return do # @a is nil
    return "It's fucking " + @a
  end
end

puts a()()

但在 Ruby 里创建块就可以捕获外围的变量
.... 我的意见是不要专门支持(因为毕竟也没啥好玩的)(或许吧)(虽然在 Java Lite 里支持这个比 C 里简单多了)(而且底层的事情完全不用操心)(哎还是支持算了,,,如果找不到就去父作用域的本地表里找)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 我太菜了,被关了起来 垃圾 duangsuse
Projects
None yet
Development

No branches or pull requests

1 participant