Closed BPerlakiH closed 3 months ago
Seems to be related to this part of the code: https://github.com/openzim/libzim/blob/f6243442dc3ac6f7c79796ce8bd877d0d4f60cf1/src/file_reader.cpp#L150C1-L156C4
Crash as well with: ./kiwix-tools_macos-x86_64-3.7.0/kiwix-serve --port=8080 canadianprepper_en_all_2023-11.zim
but linux version works fine!
@veloman-yunkan Because @mgautierfr is not available for the moment, maybe you have an idea what goes wrong here? ZIM file is not anymore at library.kiwix.org, but available at https://mega.nz/file/DdExnASY#EUnApGBiBNl1rbApKZkGDwy91V15qywiTbTey8FMjDE
It seems that the mmaping is failing for some reason.
The root cause is not obvious. It seems that we are throwing a MMapException
which should be catch internally to libzim. But it may be in the catch we fail to allocate the buffer (https://github.com/openzim/libzim/blob/f6243442dc3ac6f7c79796ce8bd877d0d4f60cf1/src/file_reader.cpp#L207)
@BPerlakiH Do you know if we have MMAP_SUPPORT_64
? (https://github.com/openzim/libzim/blob/f6243442dc3ac6f7c79796ce8bd877d0d4f60cf1/src/file_reader.cpp#L167-L171)
Might that be that mmap64 works in general but concretly only until a certain (max) size? https://forum.juce.com/t/memory-mapping-limitations-on-ios/33119
@BPerlakiH Can you test with this libzim version : https://tmp.kiwix.org/ci/dev_preview/trace_mmap_macos/libzim_macos-x86_64-2024-03-18.tar.gz ?
It contains more traces around mmap allocation.
Thank you @mgautierfr, As a matter of fact to try it out, I will need a new libkiwix build, that includes this libzim version. What is the quickest way to do that ?
Managed to compile it via kiwix-build. Here's the crash trace:
mmap with flags:2 offest:0 size:80
munmap 4912545792 size:80
pageAlignedOffset (16696311808) is too big
The variables at the point of exception:
fd int 22
offset zim::offset_t
REAL_TYPEDEF<unsigned long long, zim::offset_t> REAL_TYPEDEF<unsigned long long, zim::offset_t>
v unsigned long long 16696312332
size zim::zsize_t
REAL_TYPEDEF<unsigned long long, zim::zsize_t> REAL_TYPEDEF<unsigned long long, zim::zsize_t>
v unsigned long long 10924
pageAlignedOffset const zim::offset_type 16696311808
alignmentAdjustment const size_t 524
mmappedAddress char *const "\xa0(" 0x000000016f60ec08
*mmappedAddress char '\xa0'
munmapDeleter const (unnamed class)
mmappedAddress char *const "\f\U00000002" 0x000000016f60eb50
*mmappedAddress char '\f'
size zim::zsize_t
REAL_TYPEDEF<unsigned long long, zim::zsize_t> REAL_TYPEDEF<unsigned long long, zim::zsize_t>
v unsigned long long 4308774440
I think I have found the issue. But are you on 32bits or 64bits ?
Pr #867 should fix it. @BPerlakiH can you test it ?
When trying to open a large ZIM file as of https://github.com/kiwix/apple/issues/675
The following exception is throw, which cannot be caught by Objective-C: