Conversation
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
sstrncpy(dest, src, n) copies up to n source chars and writes the null terminator at dest[n], so the buffer must be n+1 bytes. The realpath() rework in d7c4360 passed `size` (the full buffer size) as `n`, which writes one byte past the end of InpDir when the resolved path is >= sizeof(InpDir). Pass `size - 1` instead, clear absPath on realpath() failure, and clamp the absolute-path else branch to size-1 (was previously unbounded). Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
When ctest fails on the Linux runner, re-run each of the five legacy solver test binaries under gdb to capture the backtrace in the workflow log. No-op on macOS/Windows and when ctest passes. Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Root cause of the Linux x64 Debug ctest segfaults in
test_legacy_solver_{api,errors,hotstart,shapes,expanded_api}.
The root CMakeLists sets CMAKE_C_EXTENSIONS OFF, so CMake passes
-std=c17 (strict ANSI) instead of -std=gnu17. Under __STRICT_ANSI__,
glibc's <stdlib.h> hides realpath() because it's a POSIX extension.
swmm5.c::getAbsolutePath() then calls realpath() with no visible
prototype, so gcc falls back to implicit-int — the 64-bit char*
return is truncated to 32 bits, sstrncpy() dereferences the garbage
pointer, and SIGSEGV.
gdb backtrace from the CI logs (with the gdb step added in 0daaf10):
#0 sstrncpy (dest=<InpDir>, src=0x5562ba20 <Cannot access memory>, n=259)
#1 getAbsolutePath (..., size=260) at swmm5.c:2770
#2 swmm_open (...) at swmm5.c:583
Apple's libc exposes realpath unconditionally and Windows uses the
GetFullPathName branch, which is why this only bit Linux. The
previous CI was silently building Release (-O2 -flto), where LTO
sees the real prototype across TUs and avoids the truncation;
commit a786683 unmasked the bug by letting the Debug preset
actually build Debug.
Signed-off-by: cbuahin <caleb.buahin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.