2014-01-23 27 views
0

我有一個奇怪的問題,libgdal和ECW,在centos 6.5最後。當我嘗試使用gdalinfo(或其他)讀取ECW文件時,出現分段錯誤。Centos 6.5 Final GDAL/ECW分割錯誤

這很奇怪,因爲我有很多具有相同centos和相同ecw/gdal編譯lib的虛擬機,但是這隻發生在其中一個虛擬機上。

試圖用GDB進行調試錯誤,我注意到,ECW試圖分配的2147483647個字符的字符串,但系統上的限制是1073741820.

這是不可能性告訴libgdal/libecw這max_size個限制字符串他們必須使用?有可能改變系統的max_size?

任何想法,將不勝感激:)

OS:的CentOS 6.5(最終) ECW lib目錄下:libecwj2-3.3 GDAL lib目錄下:@中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 

回答

0

我們發現問題的所在。 libecw嘗試保存prefs文件,但對於NCSUtil中的錯誤代碼,它會告知tinyxml以文件的形式打開目錄。通常這會失敗,但沒有很大的問題。 我們在哪裏經歷過tinyteml在一個系統上使用ftell()函數的奇怪行爲。

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

從FTELL的原因這壞返回值TinyXML的試圖分配一個(2^31)-1大小的字符串,這是比系統限制更大。所以一切都崩潰了。

如果有人遇到過ftell()的類似行爲,請告訴我們,我們很有興趣瞭解導致類似系統上不同結果的原因。

+1

我們也遇到過這個問題。 Libecw會將prefs文件保存在'$ HOME'目錄中。在我們的GDAL環境中取消設置'$ HOME'解決了這個問題。 –