libzim icon indicating copy to clipboard operation
libzim copied to clipboard

test/archive.cpp:627 something something shared pointer

Open ewtoombs opened this issue 1 year ago • 3 comments

My build failed with this error:


[50/133] Linking target src/libzim.so.9.1.0
/usr/bin/ld: warning: -z pack-relative-relocs ignored
[75/133] Compiling C++ object test/archive.p/archive.cpp.o
FAILED: test/archive.p/archive.cpp.o 
c++ -Itest/archive.p -Iinclude -I../include -Isrc -I../src -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -Wall -Winvalid-pch -Werror -std=c++17 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -fPIE -DGTEST_HAS_PTHREAD=1 -pthread -DWITH_TEST_DATA=1 -MD -MQ test/archive.p/archive.cpp.o -MF test/archive.p/archive.cpp.o.d -o test/archive.p/archive.cpp.o -c ../test/archive.cpp
In file included from /usr/include/c++/14.1.1/bits/shared_ptr.h:53,
                 from /usr/include/c++/14.1.1/memory:80,
                 from ../include/zim/entry.h:26,
                 from ../include/zim/archive.h:26,
                 from ../test/archive.cpp:22:
In constructor ‘std::__shared_count<_Lp>::__shared_count(_Ptr) [with _Ptr = char*; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’,
    inlined from ‘std::__shared_count<_Lp>::__shared_count(_Ptr, std::false_type) [with _Ptr = char*; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/include/c++/14.1.1/bits/shared_ptr_base.h:926:22,
    inlined from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Yp*) [with _Yp = char; <template-parameter-2-2> = void; _Tp = char; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at /usr/include/c++/14.1.1/bits/shared_ptr_base.h:1470:17,
    inlined from ‘std::shared_ptr<_Tp>::shared_ptr(_Yp*) [with _Yp = char; <template-parameter-2-2> = void; _Tp = char]’ at /usr/include/c++/14.1.1/bits/shared_ptr.h:213:46,
    inlined from ‘zim::Blob {anonymous}::readItemData(const zim::Item::DirectAccessInfo&, zim::size_type)’ at ../test/archive.cpp:627:44:
/usr/include/c++/14.1.1/bits/shared_ptr_base.h:919:15: error: ‘void operator delete(void*, std::size_t)’ called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete]
  919 |               delete __p;
      |               ^~~~~~~~~~
../test/archive.cpp: In function ‘zim::Blob {anonymous}::readItemData(const zim::Item::DirectAccessInfo&, zim::size_type)’:
../test/archive.cpp:627:43: note: returned from ‘void* operator new [](std::size_t)’
  627 |   std::shared_ptr<char> data(new char[size]);
      |                                           ^
cc1plus: all warnings being treated as errors
[82/133] Compiling C++ object test/parseLongPath.p/parseLongPath.cpp.o
ninja: build stopped: subcommand failed.

Commenting out subdir('test') in meson.build is a workaround.

architecture: aarch64 gcc version: 14.1.1+r1+g43b730b9134-1 libzim version: 9.1.0

Let me know if there is anything else you need.

ewtoombs avatar Nov 16 '24 15:11 ewtoombs

@veloman-yunkan Looks like amcompatibility problem with gcc-14. We should fix and add in CI if possible

kelson42 avatar Nov 16 '24 19:11 kelson42

@ewtoombs How to you achieve to get exactly this error. I have test myself with g++-14 on Ubuntu-22.04 and everything works fine (maybe the bug has been fixed in the meatime?)

kelson$ meson test
ninja: Entering directory `/home/kelson/code/libzim/build'
ninja: no work to do.
 1/30 lrucache                    OK               0.03s
 2/30 concurrentcache             OK               0.02s
 3/30 dirent                      OK               0.01s
 4/30 header                      OK               0.02s
 5/30 reader                      OK               0.02s
 6/30 iterator                    OK               0.10s
 7/30 find                        OK               0.20s
 8/30 dirent_lookup               OK               0.02s
 9/30 istreamreader               OK               0.03s
10/30 decoderstreamreader         OK               0.23s
11/30 rawstreamreader             OK               0.03s
12/30 bufferstreamer              OK               0.02s
13/30 parseLongPath               OK               0.03s
14/30 random                      OK               0.15s
15/30 tooltesting                 OK               0.07s
16/30 tinyString                  OK               0.03s
17/30 uuid                        OK               1.02s
18/30 compression                 OK               0.97s
19/30 counterParsing              OK               0.04s
20/30 creator                     OK               1.41s
21/30 defaultIndexdata            OK               0.03s
22/30 log                         OK               1.53s
23/30 indexing_criteria           OK               0.57s
24/30 suggestion_iterator         OK               1.09s
25/30 search_iterator             OK               1.25s
26/30 archive                     OK               5.18s
27/30 search                      OK               5.15s
28/30 suggestion                  OK               6.63s
29/30 cluster                     OK               9.45s
30/30 error_in_creator            OK              11.35s

Ok:                 30  
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

Full log written to /home/kelson/code/libzim/build/meson-logs/testlog.txt
kelson$ gcc --version
gcc (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

kelson$ g++ --version
g++ (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

kelson42 avatar May 04 '25 18:05 kelson42

@veloman-yunkan What is your feedback on this? Should I just close the issue?

kelson42 avatar Oct 08 '25 15:10 kelson42