运算符 new 是否在 THREAD 堆上分配?

发布于 2024-08-24 18:36:48 字数 457 浏览 4 评论 0原文

我的问题似乎是这样的:由一个线程分配的堆数据(后来消失)似乎也消失了。如下所示:

  1. 线程 X:启动
  2. 线程 Y:启动
  3. 线程 X:ptr = new 一些字节
  4. 线程 X:死亡
  5. 线程 Y:尝试使用 ptr - 并且崩溃!

到目前为止,我只在 Darwin(Mac OS 10.5 和 10.6)上看到过这个问题,但除了 Windows 和 Linux (Ubuntu) 之外,还没有尝试过更多其他平台,它可以按预期工作。我遇到这个问题已经有一段时间了,因此非常感谢任何有关此问题的专业知识或更多信息!

编辑:该问题是由不相关的崩溃错误。

My problem seems to be this: heap data allocated by one thread (that later dies) seems to die as well. As so:

  1. Thread X: starts
  2. Thread Y: starts
  3. Thread X: ptr = new some bytes
  4. Thread X: dies
  5. Thread Y: tries to use ptr - and crashes!

So far, I've only seen this problem on Darwin (Mac OS 10.5 and 10.6), but haven't tried more other platforms than Windows and Linux (Ubuntu) where it works as expected. I've had this problem for some time, so any know-how or more information about this is highly appreciated!

Edit: the problem was caused by an unrelated crash bug.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2024-08-31 18:36:48

线程是否有不同的堆?
该线程有一些关于这个主题的好信息

Do threads have a distinct heap?
This thread has some good information regarding this subject

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文