【问题标题】:Boost Filesystem: recursive_directory_iterator constructor causes SIGTRAPS and debug problemsBoost Filesystem:recursive_directory_iterator 构造函数导致 SIGTRAPS 和调试问题
【发布时间】:2011-03-29 00:31:09
【问题描述】:

我想使用 boost::filesystem 提供的 recursive_directory_iterator 来删除一个目录。但是在构建时,调试器停止并显示消息 Signal Received: Sigtrap 。我可以选择继续(必须执行多次,因为捕获了多个 Sigtraps)并且程序将按预期工作,但使用自定义断点进行调试不再起作用。 "fs::path dir" 指向的路径是有效的,我也尝试过使用 fs::... dirIter("D:/validPath" ) 之类的字符串,但是问题依然存在。

#include <boost/filesystem.hpp> 
namespace boost::filesystem = fs;
void recursiveDeleteDir( fs::path dir ) 
 fs::recursive_directory_iterator endIter; 
 //At this point debugging is stopped with the message
 //Signal Received: SIGTRAP
 fs::recursive_directory_iterator dirIter( dir );      
 for(;dirIter != endIter ; ++dirIter) 
 { 
  // do something 
 } 
}

当我试图找出 Sigtrap 的确切来源时,我迷失在 boost::filesystem 实现细节的深处。

有没有人知道为什么这些 Sigtraps 存在或它们是如何被激活的 更重要的是: 有没有办法摆脱它们

(当然它们只发生在调试模式下,程序在发布模式下工作正常,但我必须能够以某种方式继续调试)

感谢您的帮助!


编辑: 我正在使用 NetBeans IDE,但无权访问完整的调用堆栈。但这就是接收到 sigtrap 信号时包含的内容:

01: ntdll!RtlpNtMakeTemporaryKey()
02: ntdll!RtlpNtMakeTemporaryKey()
03: ntdll!RtlpNtMakeTemporaryKey()
04: ntdll!LdrFindEntryForAddress()
05:地址:[@0x003e0000]
06:地址:[@0x50000061]
07: std::basic_string, std::allocator>::_Rep::_S_empty_rep_storage()
08:地址:[@0x003e0000]
09: std::basic_string, std::allocator>::_Rep::_S_empty_rep_storage()
10:地址:[@0x40000060]
11:地址:[@0x0022f968]
12:地址:[@0x00000000]

【问题讨论】:

  • 您至少可以显示收到第一个 Sigtrap 时执行的确切位置的堆栈跟踪吗?我在任何地方都没有任何 Windows 系统,所以我可能无法提供帮助,但它可能会帮助其他人。

标签: c++ debugging boost


【解决方案1】:

经过大量搜索和询问,我解决了这个问题。 这个问题(或者更确切地说是答案)给了我一个提示:
Does getting random SIGTRAP signals (in MinGW-gdb) is a sign of memory corruption?

这似乎是尝试访问损坏的内存的问题,这是由于使用了未初始化的动态库引起的。

通过使用 boost::filesystem 和 boost::system 库的静态(调试)版本,并激活链接器的 -static 开关,可以解决问题。

【讨论】:

    猜你喜欢
    • 2015-06-16
    • 2018-02-13
    • 1970-01-01
    • 2013-08-25
    • 2012-03-18
    • 2020-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多