【问题标题】:Centos 6.5 Final GDAL/ECW Segmentation FaultCentos 6.5 最终 GDAL/ECW 分段错误
【发布时间】:2014-02-13 16:35:51
【问题描述】:

在 centos 6.5 final 上,我对 libgdal 和 ECW 有一个奇怪的问题。当我尝试使用 gdalinfo(或其他任何内容)读取 ECW 文件时,出现分段错误。

这很奇怪,因为我有许多具有相同 centos 和相同 ecw/gdal 编译库的虚拟机,但这只发生在其中一个上。

尝试使用 gdb 调试错误,我注意到 ecw 尝试分配 2147483647 个字符的字符串,但在系统上限制为 1073741820。

是否可以告诉 libgdal/libecw 他们必须使用的字符串的 max_size 限制?可以更改系统的 max_size 吗?

任何想法将不胜感激:)

操作系统: centos 6.5(最终版) ECW 库: libecwj2-3.3 GDAL 库: gdal 1.9.2

使用 gdalinfo 打开 ecw 文件时出错:

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_S_create
Aborted

gdb 堆栈跟踪

#0  0x00130424 in __kernel_vsyscall ()
#1  0x00e1ab11 in raise () from /lib/libc.so.6
#2  0x00e1c3ea in abort () from /lib/libc.so.6
#3  0x00d6db87 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#4  0x00d6b9e6 in ?? () from /usr/lib/libstdc++.so.6
#5  0x00d6ba23 in std::terminate() () from /usr/lib/libstdc++.so.6
#6  0x00d6bb62 in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0x00d0c960 in std::__throw_length_error(char const*) () from /usr/lib/libstdc++.so.6
#8  0x00d48ef6 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) () from /usr/lib/libstdc++.so.6
#9  0x00d4a029 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_clone(std::allocator<char> const&, unsigned int) () from /usr/lib/libstdc++.so.6
#10 0x00d4a578 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned int) () from /usr/lib/libstdc++.so.6
#11 0x00a699f3 in TiXmlDocument::LoadFile (this=0x80642e4, filename=0x8064374 "/root/", encoding=TIXML_ENCODING_UNKNOWN) at ../C/NCSEcw/NCSJP2/../../tinyxml/tinyxml.cpp:995
#12 0x00b4ae6b in CNCSPrefsXML::CNCSPrefsXML (this=0x8064280, sFilename=...) at ../C/NCSUtil/NCSPrefsXML.cpp:78
#13 0x00b4b0f0 in CNCSPrefsXML::Init () at ../C/NCSUtil/NCSPrefsXML.cpp:40
#14 0x00b46dd7 in NCSPrefInit () at ../C/NCSUtil/NCSPrefs.cpp:84
#15 0x00b4fcf5 in NCSUtilInit () at ../C/NCSUtil/util.c:81
#16 0x00ac5e90 in NCSecwInitInternal () at ../C/NCSEcw/NCSEcw/NCSEcw.cpp:335
#17 0x00ac6aa7 in NCSecwInit () at ../C/NCSEcw/NCSEcw/NCSEcw.cpp:355
#18 0x003321b7 in ECWInitialize () at ecwdataset.cpp:1891
#19 0x00335fa4 in ECWDataset::Open (poOpenInfo=0xbfff5540, bIsJPEG2000=0) at ecwdataset.cpp:1369
#20 0x0033652a in ECWDataset::OpenECW (poOpenInfo=0xbfff5540) at ecwdataset.cpp:1246
#21 0x00550163 in GDALOpenInternal (oOpenInfo=..., papszAllowedDrivers=0x0) at gdaldataset.cpp:2251
#22 0x0055077a in GDALOpenInternal (pszFilename=0x8063480 "/mnt/sdb1/mapguide_data/sienaprovincia/ortofoto_1954/1954.ecw", eAccess=GA_ReadOnly, papszAllowedDrivers=0x0) at gdaldataset.cpp:2209
#23 0x005507dc in GDALOpen (pszFilename=0x8063480 "/mnt/sdb1/mapguide_data/sienaprovincia/ortofoto_1954/1954.ecw", eAccess=GA_ReadOnly) at gdaldataset.cpp:2200
#24 0x08049eed in main (argc=2, argv=0x8063450) at gdalinfo.c:173

【问题讨论】:

    标签: c++ segmentation-fault centos gdal


    【解决方案1】:

    我们找到了问题所在。 libecw 尝试保存 prefs 文件,但是对于 NCSUtil 中的错误代码,它告诉 tinyxml 将目录作为文件打开。通常这会失败,但没有大问题。 然而,我们在一个系统上遇到了由 tinyxml 使用的 ftell() 函数的奇怪行为。

    见:https://stackoverflow.com/questions/21307977/strange-behaviour-of-ftell-on-twin-system

    来自 ftell 的错误返回值导致 tinyxml 尝试分配 (2^31)-1 大小的字符串,该字符串大于系统限制。所以一切都崩溃了。

    如果有人遇到过 ftell() 的类似行为,请告诉我们,我们很想了解导致类似系统上不同结果的原因。

    【讨论】:

    • 我们也遇到了这个问题。 Libecw 尝试将 prefs 文件保存在 $HOME 目录中。在我们的 GDAL 环境中取消设置 $HOME 解决了这个问题。
    猜你喜欢
    • 2014-04-19
    • 1970-01-01
    • 2014-02-25
    • 2014-05-24
    • 1970-01-01
    • 1970-01-01
    • 2014-05-24
    • 1970-01-01
    • 2015-01-30
    相关资源
    最近更新 更多