Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error on macOS ARM64 Apple Silicon #5

Open
glowinthedark opened this issue Dec 10, 2023 · 7 comments
Open

Compile error on macOS ARM64 Apple Silicon #5

glowinthedark opened this issue Dec 10, 2023 · 7 comments

Comments

@glowinthedark
Copy link

Compilation fails on macOS ARM64 M2

Compilation fails on macOS ventura 13.5 with qt 5.15.10

/opt/homebrew/Cellar/qt@5/5.15.10_1/bin/qmake "CONFIG+=release no_epwing_support sdk_no_version_check use_qtwebengine no_ffmpeg_player" QMAKE_APPLE_DEVICE_ARCHS="arm64" goldendict.pro
make -j 12

Qt install method: Qt installed via brew install qt@5
Qt Version: 5.15.10_1
Xcode Version: 15.0.1
qmake:

QMake version 3.1
Using Qt version 5.15.10 in /opt/homebrew/Cellar/qt@5/5.15.10_1/lib
Click for error log
linking GoldenDict.app/Contents/MacOS/GoldenDict
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libiconv.dylib': fat file missing arch 'arm64', file has 'i386,x86_64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libvorbis.dylib': fat file missing arch 'arm64', file has 'i386,x86_64,ppc'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libvorbisfile.dylib': fat file missing arch 'arm64', file has 'i386,x86_64,ppc'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libhunspell-1.6.1.dylib': fat file missing arch 'arm64', file has 'i386,x86_64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libogg.dylib': fat file missing arch 'arm64', file has 'i386,x86_64,unknown'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/liblzo2.dylib': fat file missing arch 'arm64', file has 'i386,x86_64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libtiff.dylib': fat file missing arch 'arm64', file has 'i386,x86_64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/liblzma.a': fat file missing arch 'arm64', file has 'i386,x86_64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libopencc.2.dylib': fat file missing arch 'arm64', file has 'i386,x86_64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[35](zstd_v07.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[29](cover.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[28](zbuff_decompress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[27](zbuff_compress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[26](zbuff_common.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[25](zstd_decompress_block.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[24](zstd_decompress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[23](zstd_ddict.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[22](huf_decompress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[21](zstdmt_compress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[20](zstd_opt.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[19](zstd_ldm.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[18](zstd_lazy.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[17](zstd_fast.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[16](zstd_double_fast.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[15](zstd_compress_sequences.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[14](zstd_compress_literals.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[13](zstd_compress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[12](huf_compress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[11](hist.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[10](fse_compress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[34](zstd_v06.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[9](zstd_common.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[33](zstd_v05.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[8](xxhash.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[32](zdict.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[7](threading.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[31](fastcover.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[30](divsufsort.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[6](pool.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[5](fse_decompress.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[4](error_private.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[3](entropy_common.o)': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/Users/gen/projects/macos/goldendict-webengine/maclibs/lib/libzstd.a[2](debug.o)': found architecture 'x86_64', required architecture 'arm64'
ld: Undefined symbols:
  _TIFFClientOpen, referenced from:
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
  _TIFFClose, referenced from:
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
  _TIFFGetField, referenced from:
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
  _TIFFReadScanline, referenced from:
      GdTiff::tiffToQImage(char const*, int, QImage&) in tiff.o
  _ZSTD_createDStream, referenced from:
      decompressZstd(char const*, unsigned int) in decompress.o
  _ZSTD_decompressStream, referenced from:
      decompressZstd(char const*, unsigned int) in decompress.o
  _ZSTD_freeDStream, referenced from:
      decompressZstd(char const*, unsigned int) in decompress.o
      decompressZstd(char const*, unsigned int) in decompress.o
  _ZSTD_initDStream, referenced from:
      decompressZstd(char const*, unsigned int) in decompress.o
  _ZSTD_isError, referenced from:
      decompressZstd(char const*, unsigned int) in decompress.o
      decompressZstd(char const*, unsigned int) in decompress.o
  Hunspell::get_dic_encoding(), referenced from:
      HunspellMorpho::(anonymous namespace)::encodeToHunspell(Hunspell&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>> const&) in hunspell.o
      HunspellMorpho::(anonymous namespace)::decodeFromHunspell(Hunspell&, char const*) in hunspell.o

  Hunspell::spell(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*), referenced from:
      HunspellMorpho::(anonymous namespace)::HunspellPrefixMatchRequestRunnable::run() in hunspell.o
      HunspellMorpho::(anonymous namespace)::HunspellArticleRequestRunnable::run() in hunspell.o
  Hunspell::analyze(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&), referenced from:
      HunspellMorpho::(anonymous namespace)::suggest(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>>&, Mutex&, Hunspell&) in hunspell.o
  Hunspell::suggest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&), referenced from:
      HunspellMorpho::(anonymous namespace)::HunspellArticleRequestRunnable::run() in hunspell.o
  Hunspell::Hunspell(char const*, char const*, char const*), referenced from:
      HunspellMorpho::makeDictionaries(Config::Hunspell const&) in hunspell.o
  Hunspell::~Hunspell(), referenced from:
      HunspellMorpho::(anonymous namespace)::HunspellDictionary::~HunspellDictionary() in hunspell.o
      HunspellMorpho::(anonymous namespace)::HunspellDictionary::~HunspellDictionary() in hunspell.o
  _libiconv, referenced from:
      Babylon::convertToUtf8(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, unsigned int) in bgl_babylon.o
      Babylon::convertToUtf8(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, unsigned int) in bgl_babylon.o
      Iconv::convert(void const*&, unsigned long&, void*&, unsigned long&) in iconv.o
      Mdict::MdictParser::toUtf16(char const*, char const*, unsigned long) in mdictparser.o
  _libiconv_close, referenced from:
      Babylon::convertToUtf8(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, unsigned int) in bgl_babylon.o
      Babylon::convertToUtf8(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, unsigned int) in bgl_babylon.o
      Iconv::reinit(char const*, char const*) in iconv.o
      Iconv::~Iconv() in iconv.o
      Iconv::~Iconv() in iconv.o
      Iconv::toWstring(char const*, void const*, unsigned long) in iconv.o
      Iconv::toWstring(char const*, void const*, unsigned long) in iconv.o
      ...
  _libiconv_open, referenced from:
      Babylon::convertToUtf8(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&, unsigned int) in bgl_babylon.o
      Iconv::Iconv(char const*, char const*) in iconv.o
      Iconv::reinit(char const*, char const*) in iconv.o
      Mdict::MdictParser::toUtf16(char const*, char const*, unsigned long) in mdictparser.o
  _lzma_code, referenced from:
      decompressLzma2(char const*, unsigned int, bool) in decompress.o
  _lzma_end, referenced from:
      decompressLzma2(char const*, unsigned int, bool) in decompress.o
  _lzma_lzma_preset, referenced from:
      decompressLzma2(char const*, unsigned int, bool) in decompress.o
  _lzma_raw_decoder, referenced from:
      decompressLzma2(char const*, unsigned int, bool) in decompress.o
  _lzma_stream_decoder, referenced from:
      decompressLzma2(char const*, unsigned int, bool) in decompress.o
  _lzo1x_decompress_safe, referenced from:
      Mdict::MdictParser::parseCompressedBlock(long long, char const*, long long, QByteArray&) in mdictparser.o
  _lzo_adler32, referenced from:
      Mdict::MdictParser::parseCompressedBlock(long long, char const*, long long, QByteArray&) in mdictparser.o
      Mdict::MdictParser::parseCompressedBlock(long long, char const*, long long, QByteArray&) in mdictparser.o
  _opencc_close, referenced from:
      Chinese::CharacterConversionDictionary::~CharacterConversionDictionary() in chinese.o
      Chinese::CharacterConversionDictionary::~CharacterConversionDictionary() in chinese.o
      Chinese::CharacterConversionDictionary::~CharacterConversionDictionary() in chinese.o
  _opencc_convert_utf8, referenced from:
      Chinese::CharacterConversionDictionary::getAlternateWritings(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>> const&) in chinese.o
  _opencc_convert_utf8_free, referenced from:
      Chinese::CharacterConversionDictionary::getAlternateWritings(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>> const&) in chinese.o
  _opencc_error, referenced from:
      Chinese::CharacterConversionDictionary::CharacterConversionDictionary(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, QIcon, QString const&) in chinese.o
      Chinese::CharacterConversionDictionary::getAlternateWritings(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>> const&) in chinese.o
  _opencc_open, referenced from:
      Chinese::CharacterConversionDictionary::CharacterConversionDictionary(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, QIcon, QString const&) in chinese.o
  _ov_clear, referenced from:
      Lsa::(anonymous namespace)::LsaDictionary::getResource(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in lsa.o
      Lsa::(anonymous namespace)::LsaDictionary::getResource(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in lsa.o
  _ov_info, referenced from:
      Lsa::(anonymous namespace)::LsaDictionary::getResource(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in lsa.o
  _ov_open_callbacks, referenced from:
      Lsa::(anonymous namespace)::LsaDictionary::getResource(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in lsa.o
  _ov_pcm_seek, referenced from:
      Lsa::(anonymous namespace)::LsaDictionary::getResource(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in lsa.o
  _ov_read, referenced from:
      Lsa::(anonymous namespace)::LsaDictionary::getResource(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in lsa.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [GoldenDict.app/Contents/MacOS/GoldenDict] Error 1
@vedgy
Copy link
Owner

vedgy commented Dec 10, 2023

Have you tried merging #1 locally?

@glowinthedark
Copy link
Author

glowinthedark commented Dec 10, 2023

@vedgy:

Have you tried merging #1 locally?

Nice! wasn't aware of that pr! Didn't try yet.

What I did was replace all the binary libs with arm64 flavours, i.e. with something the following

rm -rf maclibs/lib/*
cp -L /opt/homebrew/lib/libhunspell-1.7.0.dylib maclibs/lib
cp -L /opt/homebrew/Cellar/libiconv/1.17/lib/libiconv.dylib maclibs/lib
cp -L /opt/homebrew/lib/libogg.dylib maclibs/lib
cp -L /opt/homebrew/lib/liblzo2.dylib maclibs/lib
cp -L /opt/homebrew/lib/libtiff.dylib maclibs/lib
cp -L /opt/homebrew/lib/liblzma.dylib maclibs/lib
cp -L /opt/homebrew/lib/libopencc.dylib maclibs/lib
cp -L /opt/homebrew/lib/libzstd.a maclibs/lib
cp -L /opt/homebrew/Cellar/libao/1.2.2/lib/libao.dylib maclibs/lib
cp -L /opt/homebrew/Cellar/ffmpeg/6.0_1/lib/libavcodec.dylib maclibs/lib
cp -L /opt/homebrew/Cellar/ffmpeg/6.0_1/lib/libavformat.dylib maclibs/lib
cp -L /opt/homebrew/Cellar/ffmpeg/6.0_1/lib/libavutil.dylib maclibs/lib
cp -L /usr/local/lib/libeb.dylib maclibs/lib
cp -L /opt/homebrew/Cellar/hunspell/1.7.2/lib/libhunspell-1.7.dylib maclibs/lib
cp -L /opt/homebrew/lib/liblzma.a maclibs/lib
cp -L /opt/homebrew/Cellar/opencc/1.1.6/lib/libopencc.dylib maclibs/lib
cp -L /opt/homebrew/lib/libswresample.4.dylib maclibs/lib
cp -L /opt/homebrew/lib/libvorbisfile.3.dylib maclibs/lib
cp -L /opt/homebrew/lib/libvorbis.dylib maclibs/lib
mkdir -p maclibs/lib/ao
cp -L /opt/homebrew/Cellar/libao/1.2.2/lib/ao/plugins-4/libmacosx.so maclibs/lib/ao

Replacing x64 libs with the arm64 libs + adjusting the file names made the build compile just fine.

@glowinthedark
Copy link
Author

glowinthedark commented Dec 10, 2023

@vedgy: With #1 there are compiler version errors with Xcode 15.0.1 (macos sdk 14.0); this might be related to https://stackoverflow.com/a/70778475/191246

compiler log: https://pastebin.com/2XR315fd

@vedgy
Copy link
Owner

vedgy commented Dec 11, 2023

compiler log: https://pastebin.com/2XR315fd

error "Qt requires a C++17 compiler"

Qt 5 requires C++11 or later. Qt 6 requires C++17 or later. GoldenDict does not support Qt 6 yet. Make sure to build against Qt 5.

@glowinthedark
Copy link
Author

glowinthedark commented Dec 11, 2023

@vedgy:

Make sure to build against Qt 5.

as mentioned in the original description, in both cases the command was the same:

/opt/homebrew/Cellar/qt@5/5.15.10_1/bin/qmake "CONFIG+=release no_epwing_support sdk_no_version_check use_qtwebengine no_ffmpeg_player" QMAKE_APPLE_DEVICE_ARCHS="arm64" goldendict.pro
make -j 12

this does work fine with the master branch (after replacing the dylibs), but the same command fails with code from pr #1 — looks to me like it's something wrong with the config in goldendict.pro

@vedgy
Copy link
Owner

vedgy commented Dec 11, 2023

Maybe this part of the diff in #1 is at fault:

+    INCLUDEPATH += /opt/homebrew/include
+    LIBS += -L/opt/homebrew/lib -framework AppKit -framework Carbon

See also the pull request's changes to README.md. An extract:

NOTE: The current version of qt is Qt6, which I've been unable to compile successfully. So you either not to install the qt package, but install qt@5 or do the following:

brew unlink qt && brew link qt@5

@glowinthedark
Copy link
Author

glowinthedark commented Dec 11, 2023

@vedgy: Yes, that was indeed the root cause! — I had both qt@5 and qt (6) installed. after brew rm qt the compilation with #1 succeeded. Thanks!

vedgy added a commit that referenced this issue Jan 8, 2024
Comparison operators for MdictParser::RecordIndex and qint64 use
RecordIndex's data members shadowStartPos and shadowEndPos. The binary
search in MdictParser::RecordIndex::bsearch() uses these comparison
operators to find a qint64 in an ordered RecordIndex collection.
The condition for a bsearch() in MdictParser::readRecordBlock() uses
RecordIndex's data member endPos in place of shadowEndPos by mistake.

Assignments a few lines below in readRecordBlock() confirm that this is
a mistake:
    RecordIndex const & recordIndex = recordBlockInfos_[idx];
...
      recordSize = recordIndex.shadowEndPos - i->first;
...
    recordInfo.recordSize = recordSize;
MdictParser::RecordInfo::recordSize must be non-negative because it is
used as a size. For example, in
IndexedMdd::loadFile(gd::wstring const &, std::vector<char> & result):
    result.resize( indexEntry.recordSize );
std::vector::resize() takes an unsigned size_type argument. Passing a
negative integer to it would attempt to resize to a huge size close to
the maximum value of std::vector::size_type.

There are two practical consequences of this mistake:
1. An affected image is never displayed in the article view.
2. GoldenDict occasionally crashes while loading an affected article.

I can consistently reproduce the crash by running a Debug build of
GoldenDict via GDB and loading the single article of the affected
dictionary attached to goldendict#1672. The backtrace:
    Thread 7 "Thread (pooled)" received signal SIGSEGV, Segmentation fault.
    #0  in  () at /usr/lib/libc.so.6
    #1  in Mdx::IndexedMdd::loadFile(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::vector<char, std::allocator<char> >&)
        (this=0x55555639d5d0, name=L"\\OPEU4_0002.png", result=std::vector of length 1993913, capacity 1993913 = {...}) at ../mdx.cc:184
    #2  in Mdx::MddResourceRequest::run() (this=0x555556c15f90)
        at ../mdx.cc:849
    #3  in Mdx::MddResourceRequestRunnable::run()
        (this=0x555556c163d0) at ../mdx.cc:791
    #4  in  () at /usr/lib/libQt5Core.so.5
    #5  in  () at /usr/lib/libQt5Core.so.5
    goldendict#6  in  () at /usr/lib/libc.so.6
    goldendict#7  in  () at /usr/lib/libc.so.6

Correct the mistake in readRecordBlock() and increment the Mdict format
version, because the crash goes away only after reindexing an affected
dictionary.

Fixes goldendict#1672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants