【发布时间】:2016-11-19 00:15:03
【问题描述】:
向已停止的 vibe.d 任务发送消息时,应用程序出现分段错误。我没想到消息会被传递,但会收到有关发送尝试失败的通知(或至少不会崩溃)。
下面的例子说明了这个问题。
import std.stdio;
import core.thread;
import vibe.core.core;
import vibe.core.concurrency;
static this() {
Task t = runTask({
writeln("Hi");
});
t.join;
t.send(42);
writeln("Bye");
}
运行上述代码时,输出为:
Hi
Program exited with code -11
...而不是:
Hi
Bye
调用堆栈如下所示。
#0 0x00007ffff6dbd346 in std.concurrency.MessageBox.put(ref std.concurrency.Message) ()
from /usr/lib64/libphobos2.so.0.71
#1 0x000000000051b0b3 in std.concurrency._send!(int)._send(std.concurrency.MsgType, std.concurrency.Tid, int) (_param_2=42, tid=..., type=<incomplete type>)
at /opt/dmd-2.071/import/std/concurrency.d:640
#2 0x000000000051b06d in std.concurrency._send!(int)._send(std.concurrency.Tid, int) (
_param_1=42, tid=...) at /opt/dmd-2.071/import/std/concurrency.d:629
#3 0x000000000051b04b in std.concurrency.send!(int).send(std.concurrency.Tid, int) (
_param_1=42, tid=...) at /opt/dmd-2.071/import/std/concurrency.d:605
#4 0x000000000051b027 in vibe.core.concurrency.send!(int).send(vibe.core.task.Task, int) (
_param_1=42, task=...)
at /home/user/.dub/packages/vibe-d-0.7.30/vibe-d/source/vibe/core/concurrency.d:1239
#5 0x0000000000517b6b in app._staticCtor1() () at /tmp/test/source/app.d:11
...
- 如何防止段错误?是否有检查发送功能?如何在 vibe.d 或 phobos2 中对此进行修补?
- 是 vibe.d 还是 phobos2 的 bug?
【问题讨论】: