cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

small improvements to `Path::getAbsolutePath()`

Open firewave opened this issue 1 year ago • 5 comments

  • fixed result on Linux if parts discarded by .. do not exist
  • small adjustments to Windows implementation to match Linux one

firewave avatar Jun 20 '24 22:06 firewave

Docker registry appears to be temporarily unavailable:

Error response from daemon: Head "https://registry-1.docker.io/v2/library/ubuntu/manifests/16.04": received unexpected HTTP status: 503 Service Unavailable

firewave avatar Jun 20 '24 22:06 firewave

Docker registry appears to be temporarily unavailable:

Error response from daemon: Head "https://registry-1.docker.io/v2/library/ubuntu/manifests/16.04": received unexpected HTTP status: 503 Service Unavailable

Appears to be working again.

firewave avatar Jun 20 '24 23:06 firewave

This now crashes in Cygwin:

Thread 1 "testrunner" received signal SIGABRT, Aborted.
0x00007ff87dd6d5e4 in ntdll!ZwWaitForSingleObject ()
   from /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll
(gdb) bt
#0  0x00007ff87dd6d5e4 in ntdll!ZwWaitForSingleObject ()
   from /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll
#1  0x00007ff87b5b1c4e in WaitForSingleObjectEx ()
   from /cygdrive/c/WINDOWS/System32/KERNELBASE.dll
#2  0x00007ff801d8ba60 in sigfillset () from /usr/bin/cygwin1.dll
#3  0x00007ff801d8793b in sched_getscheduler () from /usr/bin/cygwin1.dll
#4  0x00007ff801d87d11 in sched_getscheduler () from /usr/bin/cygwin1.dll
#5  0x00007ff801ed71d8 in cygwin1!abort () from /usr/bin/cygwin1.dll
#6  0x000000057b1a548e in cygstdc++-6!_ZN9__gnu_cxx27__verbose_terminate_handlerEv () from /usr/bin/cygstdc++-6.dll
#7  0x000000057b19bb86 in cygstdc++-6!_ZN10__cxxabiv111__terminateEPFvvE ()
   from /usr/bin/cygstdc++-6.dll
#8  0x000000057b29da73 in cygstdc++-6!.cxa_call_terminate ()
   from /usr/bin/cygstdc++-6.dll
#9  0x000000057b19befc in cygstdc++-6!_ZN10__cxxabiv129__pointer_to_member_type_infoD2Ev () from /usr/bin/cygstdc++-6.dll
#10 0x000000050caacbc5 in cyggcc_s-seh-1!_GCC_specific_handler ()
   from /usr/bin/cyggcc_s-seh-1.dll
#11 0x000000057b29e955 in cygstdc++-6!.gxx_personality_seh0 ()
   from /usr/bin/cygstdc++-6.dll
#12 0x00007ff87dd7292f in ntdll!.chkstk ()
   from /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll
#13 0x00007ff87dd22554 in ntdll!RtlRaiseException ()
   from /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll
#14 0x00007ff87dd7143e in ntdll!KiUserExceptionDispatcher ()
   from /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll
#15 0x00007ff87b5bba99 in RaiseException ()
   from /cygdrive/c/WINDOWS/System32/KERNELBASE.dll
#16 0x000000050caacca1 in cyggcc_s-seh-1!_Unwind_RaiseException ()
   from /usr/bin/cyggcc_s-seh-1.dll
#17 0x000000057b29e0fb in cygstdc++-6!.cxa_throw ()
   from /usr/bin/cygstdc++-6.dll
#18 0x000000057b29f793 in cygstdc++-6!_ZSt20__throw_system_errori ()
   from /usr/bin/cygstdc++-6.dll
#19 0x000000010107175b in std::mutex::lock (
    this=0x101603150 <realFilePathMap+48>)
    at /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/std_mutex.h:104
#20 0x0000000100ff9dba in std::lock_guard<std::mutex>::lock_guard (
    this=0x7ffffb990, __m=...)
    at /usr/lib/gcc/x86_64-pc-cygwin/11/include/c++/bits/std_mutex.h:229
#21 0x000000010091770b in RealFileNameMap::getCacheEntry (
    this=0x101603120 <realFilePathMap>, path=..., returnPath=...)
    at externals/simplecpp/simplecpp.cpp:2362
#22 0x00000001004077a5 in realFilename (f=...)
    at externals/simplecpp/simplecpp.cpp:2430
#23 0x0000000100407f08 in simplecpp::simplifyPath (path=...)
    at externals/simplecpp/simplecpp.cpp:2565
#24 0x000000010066470a in Path::simplifyPath (originalPath=...)
    at lib/path.cpp:91
#25 0x0000000100665974 in Path::getAbsoluteFilePath (filePath=...)
    at lib/path.cpp:372
#26 0x000000010065061e in Library::load (this=0x7ffffc338,
    exename=0x57b2a25b8 <cygstdc++-6!_ZNSs4_Rep20_S_empty_rep_storageE+24> "",
    path=0x101362178 <__gnu_cxx::__default_lock_policy+68> "std.cfg",
    debug=false) at lib/library.cpp:139
#27 0x000000010041ad9f in TestFixture::SettingsBuilder::library (
    this=0x7ffffc1b0,
    lib=0x101362178 <__gnu_cxx::__default_lock_policy+68> "std.cfg")
    at test/fixture.cpp:458
#28 0x0000000100914fc5 in TestValueFlow::TestValueFlow (
    this=0x101662840 <(anonymous namespace)::instance_TestValueFlow>)
    at test/testvalueflow.cpp:42
#29 0x000000010042c6f1 in __static_initialization_and_destruction_0 (
    __initialize_p=1, __priority=65535) at test/testvalueflow.cpp:8566
#30 0x000000010042c72f in _GLOBAL__sub_I_testvalueflow.cpp(void) ()
    at test/testvalueflow.cpp:8566
#31 0x00007ff801d1664d in cygwin1!.main () from /usr/bin/cygwin1.dll
#32 0x000000010041e1d3 in main (argc=1, argv=0xa00001b30) at test/main.cpp:27

firewave avatar Jun 21 '24 13:06 firewave

Looks like it is caused by the static initialization order. So this requires https://trac.cppcheck.net/ticket/12080 to be fixed first.

firewave avatar Jun 21 '24 13:06 firewave

We could also make the cache in simplecpp optional.

Nevertheless these caches are completely horrible and need to be implemented in a different way.

firewave avatar Jul 01 '24 08:07 firewave

The crash is fixed because the test fixtures are no longer global objects which depend on the initialization order.

firewave avatar Aug 14 '24 17:08 firewave

We could also make the cache in simplecpp optional.

Nevertheless these caches are completely horrible and need to be implemented in a different way.

I filed https://github.com/danmar/simplecpp/issues/361 upstream.

firewave avatar Sep 18 '24 10:09 firewave