]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 5528: tests/testRock fails on Solaris (#2324) auto master
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 25 Dec 2025 11:28:42 +0000 (11:28 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 25 Dec 2025 11:28:53 +0000 (11:28 +0000)
    with stub time| FATAL: Ipc::Mem::Segment::create failed to
    shm_open(squid-0-tr_rebuild_stats.shm): (22) Invalid argument

Instance::NamePrefix() stub implementation ignored `head` and `tail`
arguments, resulting in malformed shared memory segment names on
Solaris. Other tested OSes tolerate the lack of a leading "/" character.
Linux shm_open(3) recommends "/somename" format "for portable use".

Simply adding `head` and `tail` to `NamePrefix()` result fixes tests on
Solaris but breaks tests on MacOS. We shortened the result (by removing
pid_filename hash component mimicking) to avoid that breakage and
detailed the problem in a C++ comment. More work is needed to replace
human-friendly name components with shorter hashes [on MacOS].

src/tests/stub_Instance.cc

index 72fa443065cd70fb54b1ba2a330547e870369517..7a21e08fabd8d4b4c2ad452f1a5b29cfdf2139ca 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "squid.h"
 #include "Instance.h"
-#include "sbuf/SBuf.h"
+#include "sbuf/Stream.h"
 
 #define STUB_API "Instance.cc"
 #include "tests/STUB.h"
 void Instance::ThrowIfAlreadyRunning() STUB
 void Instance::WriteOurPid() STUB
 pid_t Instance::Other() STUB_RETVAL({})
-SBuf Instance::NamePrefix(const char *, const char *) STUB_RETVAL_NOP(SBuf("squid-0"))
 
+// Return what Instance.cc NamePrefix() would return using default service_name
+// and no pid_filename hash value. XXX: Mimicking pid_filename hashing triggers
+// ENAMETOOLONG errors on MacOS due to 31-character PSHMNAMLEN limit. We want to
+// use "squid-0000" here, but even `/squid-0-tr_rebuild_versions.shm` is one
+// character too long! The same limit also affects some Instance.cc NamePrefix()
+// callers -- Squid SMP caching support on MacOS is incomplete.
+SBuf Instance::NamePrefix(const char * const head, const char * const tail) STUB_RETVAL_NOP(ToSBuf(head, "squid", (tail ? tail : "")))