Hal Finney 通信

回复:bitcoin 0.1.0 崩溃

中本聪 · 2009 年 1 月 10 日 · 18:55(原件未注明时区)

SN-10220 附来源、原文与上下文。

阅读语言

我定位到问题了。如果我创建一个线程,并在里面调用 mapAddresses.count,哪怕这是程序做的第一件事,也会发生段错误。临时解决办法是在主线程里额外调用一次 mapAddresses.count,此后就一切正常了。我不愿意把问题归咎于编译器,以前也从没遇到过 GCC 编译器的错误,但这次感觉像是。也许是某段初始化代码,如果没有在同一个线程里至少调用一次,就会被它优化掉;也可能是某种不适合多线程的 STL 优化。做了那么多压力测试,发布却被这件事搞砸,实在让我沮丧。

I isolated the problem. If I spawn a thread and do mapAddresses.count, even as the very first thing in the program, it segfaults. The workaround is to needlessly call mapAddresses.count in the main thread once and it's fine from then on. I hate to blame the compiler, and I've never had a GCC compiler bug before, but this feels like one. Maybe some bit of init code it tries to optimize out if it's not called at least once in the same thread, or some STL optimization that's not thread friendly. I'm really dismayed to have this botch up the release after all that stress testing.

附件 bitcoin-0.1.1.rar(文件大小 2,132,686)是删掉了 mapAddresses.count 那一行的版本,应该是最稳妥的版本。(那是唯一一处调用 mapAddresses.count 的地方。)如果你能试试这个版本,确认崩溃已经修复,我会很感激。

The attached file: bitcoin-0.1.1.rar (filesize 2,132,686) is the version where I deleted the mapAddresses.count line, and that should be the safest version. (that was the only use of mapAddresses.count) If you could try this version and confirm that the crash is fixed, I'd appreciate it.

谢谢, Satoshi

Thanks, Satoshi

来源

阅读字号

选择适合你的字号,之后阅读会继续使用。