奇怪的“总线错误” 在 string::string 构造函数中
我一直在测试负责填充 multimap 对象的部分代码,这时开始弹出一个奇怪的错误:
int SetPortName(string ID, string Name)
cout << "ID: " << ID << " Name: " << Name;
...
}
在 FreeBSD 5.4 中的非 root 用户下工作正常,但在 root 下运行时因“总线错误”而崩溃。
I've been testing part of my code responsible for filling multimap object, when a weird error started to pop up:
int SetPortName(string ID, string Name)
cout << "ID: " << ID << " Name: " << Name;
...
}
works fine under non-root user in FreeBSD 5.4, but crashes with "Bus error" while ran under root.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标题提到了有关
string
构造函数的内容,但由于您没有显示任何调用构造函数的代码,因此我不得不假设问题实际上出在调用者中 > 该函数,其中将为参数构造两个string
对象。 我的猜测是,您的两个实际参数之一是 char*,并且它是一个空指针。 使用调试器进一步调查。The title mentions something about
string
's constructor, but since you don't show any code that calls a constructor, I'm forced to assume the problem is actually in the caller of this function, where twostring
objects would be constructed for the parameters. My guess is that one of your two actual parameters is achar*
, and it's a null pointer. Use your debugger to investigate further.