C++ std::stringstream 似乎会导致 SunOS 下的线程挂起或死亡

发布于 2024-08-30 14:30:48 字数 1114 浏览 4 评论 0原文

我有一个在 Linux 下使用 GCC 4.2 开发的应用程序,它大量使用字符串流来包装和解开通过线路发送的数据。 (因为我正在使用的 Grid API 需要它)。在 Linux 下一切都很好,但是当我部署到 SunOS(运行 SPARC 的 v5.10)并使用 GCC 3.4.6 进行编译时,应用程序在达到使用字符串流的点时挂起。

****新信息添加于 9/7/2010**** 所以我仍然没有解决这个问题,但经过大量修补后我终于找到了线索。事实上,我认为我发现了问题,但我不知道如何解决它!请参阅下面的链接器输出:

ld: warning: symbol `typeinfo for std::basic_iostream<char, std::char_traits<char> >' has differing sizes:
        (file /home/roony/dssdk/cppdriver/lib/libdsDriverGCC3.so value=0x28; file /usr/sfw/lib/libstdc++.so value=0x20);
        /home/roony/dssdk/cppdriver/lib/libdsDriverGCC3.so definition taken

因此警告表示两个库之间的 iostream 等定义不匹配,但如何修复或覆盖其中一个。 ****新信息结束****

更详细地说:主线程接受来自客户端的请求,并启动一个新的 pthread 来处理每个请求。子线程使用字符串流来打包数据。当子线程到达该点时,它似乎会挂起一秒钟然后死亡。主线程不受影响。

stringstream 和 GCC 3.4.6 或 SunOS 或 SPARC 是否存在任何已知问题?我还没有找到任何东西...

任何人都可以建议一种更好的方法来打包和解包大量字符串或字节流数据吗?

很抱歉没有发布代码,但这对我来说似乎比简单的语法错误更复杂。尽管如此,线程崩溃了:

std::stringstream mystringstream;  //not here
mystringstream << "some data: ";   //but here

也就是说,我可以声明字符串流,但是当我尝试使用它时出了问题。

I have an application developed under Linux with GCC 4.2 which makes quite heavy use of stringstreams to wrap and unwrap data being sent over the wire. (Because the Grid API I'm using demands it). Under Linux everything is fine but when I deploy to SunOS (v5.10 running SPARC) and compile with GCC 3.4.6 the app hangs when it reaches the point at which stringstreams are used.

****New Information added 9/7/2010****
So I still didn't solve this but after a lot of tinkering around I finally found a clue. In fact I think I found the problem but I'm at a loss how to fix it! See linker output below:

ld: warning: symbol `typeinfo for std::basic_iostream<char, std::char_traits<char> >' has differing sizes:
        (file /home/roony/dssdk/cppdriver/lib/libdsDriverGCC3.so value=0x28; file /usr/sfw/lib/libstdc++.so value=0x20);
        /home/roony/dssdk/cppdriver/lib/libdsDriverGCC3.so definition taken

So the warning says there is a mismatch in the definition of iostream etc between the two libraries but how to fix, or override one or the other..
****End new information****

In more detail: The main thread accepts requests from clients and starts a new pthread to handle each request. The child thread uses stringstreams to pack data. When the child thread gets to that point it seems to hang for a second and then die. The main thread is unaffected.

Are there any known issues with stringstream and GCC 3.4.6 or SunOS or SPARCs? I didn't find anything yet...

Can anyone suggest a better way to pack and unpack large amounts of data a strings or byte streams?

Apologies for not posting code but this to me seems more involved than a simple syntax error. All the same, the thread crashes:

std::stringstream mystringstream;  //not here
mystringstream << "some data: ";   //but here

That is, I can declare the stringstream but when I try to use it something goes wrong.

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

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

发布评论

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

评论(2

宫墨修音 2024-09-06 14:30:48

您想要放入流中的“某些数据”可能是无效的(例如已经释放或未正确分配的 char*...)或者数据被不同的线程修改同时。

Probably the "some data" you want to put into the stream is invalid (for example already freed or char*s that are not properly allocated/...) or the data is modified by a different thread at the same time.

空‖城人不在 2024-09-06 14:30:48

我在 SunOS 上工作时在 POSIX 合规性方面运气不佳。但这可能既不在这里也不在那里。

我想到的最直接的事情是尝试增加线程的堆栈大小。也许您在 SunOS 上的堆栈已用完。 Linux 有一个非常大且慷慨的默认堆栈大小。我不确定SunOS。

I've had really bad luck working on SunOS with regards to POSIX compliance. But that may be neither here nor there.

The most immediate thing that comes to my mind is to try increasing your stack sizes for your threads. Perhaps you are running out of stack on SunOS. Linux has a very large and generous default stack size. I'm not sure about SunOS.

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