openzim / libzim

Reference implementation of the ZIM specification
https://download.openzim.org/release/libzim/
GNU General Public License v2.0
163 stars 47 forks source link

New crash scenario of the libzim with corrupted ZIM file #893

Closed kelson42 closed 1 month ago

kelson42 commented 1 month ago
$ zimcheck ./share/kiwix/gutenberg_fr_all_2023-08.zim
[INFO] Checking zim file ./share/kiwix/gutenberg_fr_all_2023-08.zim
[INFO] Zimcheck version is 3.4.1
[INFO] Verifying ZIM-archive structure integrity...
Checksum doesn't match
  [ERROR] ZIM file's low level structure is invalid
[INFO] Avoiding redundant checksum test (already performed by the integrity check).
[INFO] Checking metadata...
[INFO] Searching for Favicon...
[INFO] Searching for main page...
[INFO] Verifying Articles' content...

Assertion failed at ../src/cluster.cpp:119
 new_offset[8267873] >= offset[3401597184]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_Z15_on_assert_failIjjEvPKcS1_S1_T_T0_S1_i+0x1c7) [0x7e28619761ff]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZN3zim7Cluster11read_headerIjEEvv+0x1c8) [0x7e2861974f24]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZN3zim7ClusterC1ESt10unique_ptrINS_13IStreamReaderESt14default_deleteIS2_EENS0_11CompressionEb+0xad) [0x7e2861973057]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZN9__gnu_cxx13new_allocatorIN3zim7ClusterEE9constructIS2_JSt10unique_ptrINS1_13IStreamReaderESt14default_deleteIS6_EERNS2_11CompressionERbEEEvPT_DpOT0_+0xa1) [0x7e2861978c9f]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZNSt16allocator_traitsISaIN3zim7ClusterEEE9constructIS1_JSt10unique_ptrINS0_13IStreamReaderESt14default_deleteIS6_EERNS1_11CompressionERbEEEvRS2_PT_DpOT0_+0x66) [0x7e2861978912]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZNSt23_Sp_counted_ptr_inplaceIN3zim7ClusterESaIS1_ELN9__gnu_cxx12_Lock_policyE2EEC2IJSt10unique_ptrINS0_13IStreamReaderESt14default_deleteIS8_EERNS1_11CompressionERbEEES2_DpOT_+0xd9) [0x7e28619783f7]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EEC1IN3zim7ClusterESaIS5_EJSt10unique_ptrINS4_13IStreamReaderESt14default_deleteIS8_EERNS5_11CompressionERbEEERPT_St20_Sp_alloc_shared_tagIT0_EDpOT1_+0x104) [0x7e2861977b26]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZNSt12__shared_ptrIN3zim7ClusterELN9__gnu_cxx12_Lock_policyE2EEC2ISaIS1_EJSt10unique_ptrINS0_13IStreamReaderESt14default_deleteIS8_EERNS1_11CompressionERbEEESt20_Sp_alloc_shared_tagIT_EDpOT0_+0x7e) [0x7e286197706a]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZNSt10shared_ptrIN3zim7ClusterEEC1ISaIS1_EJSt10unique_ptrINS0_13IStreamReaderESt14default_deleteIS6_EERNS1_11CompressionERbEEESt20_Sp_alloc_shared_tagIT_EDpOT0_+0x6b) [0x7e28619766d7]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZSt15allocate_sharedIN3zim7ClusterESaIS1_EJSt10unique_ptrINS0_13IStreamReaderESt14default_deleteIS4_EERNS1_11CompressionERbEESt10shared_ptrIT_ERKT0_DpOT1_+0x66) [0x7e2861975745]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZSt11make_sharedIN3zim7ClusterEJSt10unique_ptrINS0_13IStreamReaderESt14default_deleteIS3_EERNS1_11CompressionERbEESt10shared_ptrIT_EDpOT0_+0x82) [0x7e286197472c]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZN3zim7Cluster4readERKNS_6ReaderENS_8offset_tE+0x6a) [0x7e2861972f5e]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZN3zim8FileImpl11readClusterENS_15cluster_index_tE+0x61) [0x7e2861985503]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(+0x18557a) [0x7e286198557a]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(+0x187565) [0x7e2861987565]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZN3zim8FileImpl10getClusterENS_15cluster_index_tE+0x119) [0x7e28619856ad]
/usr/local/lib/x86_64-linux-gnu/libzim.so.9(_ZNK3zim4Item7getSizeEv+0x58) [0x7e28619a5592]
zimcheck(+0x2cffe) [0x5d3689cacffe]
zimcheck(+0x2cf4f) [0x5d3689cacf4f]
zimcheck(+0x2f1ef) [0x5d3689caf1ef]
zimcheck(+0x2ee3f) [0x5d3689caee3f]
zimcheck(+0x350f8) [0x5d3689cb50f8]
zimcheck(+0x350bb) [0x5d3689cb50bb]
zimcheck(+0x35068) [0x5d3689cb5068]
zimcheck(+0x3503c) [0x5d3689cb503c]
zimcheck(+0x35020) [0x5d3689cb5020]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xdc253) [0x7e28612dc253]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3) [0x7e2860e94ac3]
/lib/x86_64-linux-gnu/libc.so.6(+0x126850) [0x7e2860f26850]
terminate called after throwing an instance of 'std::runtime_error'
  what():  
Assertion failed at ../src/cluster.cpp:119
 new_offset[8267873] >= offset[3401597184]
Aborted (core dumped)

... kiwix-desktop crashes as well.

mgautierfr commented 1 month ago

I cannot reproduce. My setup:

Can you share your zim file ?

kelson42 commented 1 month ago

@mgautierfr Sorry, bug report was incomplete, here is the corrupted ZIM file https://tmp.kiwix.org/corrupted_zim_crash/gutenberg_fr_all_2023-08.zim