Skip to content

feat: consolidated PVS-Studio static analysis fixes & documentation update - #89

Open
bivex wants to merge 13 commits into
nimble-code:masterfrom
bivex:dev
Open

feat: consolidated PVS-Studio static analysis fixes & documentation update#89
bivex wants to merge 13 commits into
nimble-code:masterfrom
bivex:dev

Conversation

@bivex

@bivex bivex commented Aug 9, 2026

Copy link
Copy Markdown

Summary

This branch (dev) combines all recent fixes and updates for the Spin codebase:

  1. Documentation: Modernized and comprehensive README.md.
  2. PVS-Studio High Level (Level 1) Fixes:
    • Buffer overflow and bounds checking in main.c
    • 64-bit termios bitmask truncation in mesg.c
    • NULL pointer guards in pangen2.c, pangen3.c, and run.c
    • 64-bit unsigned long bit shifts (1UL << j) in pangen6.c
    • Division-by-zero guard in run.c
  3. PVS-Studio Medium Level (Level 2) Fixes:
    • Array & string index bounds checks in guided.c, msc_tcl.c, and structs.c
    • Target 1D buffer size check in spinlex.c (sizeof(IArg_cont[IArgno]))
    • Null safety in pangen5.c, flow.c, mesg.c, pangen1.c, and sym.c
    • Fallthrough annotations and boolean simplification in pangen2.c
  4. PVS-Studio Low Level (Level 3) Fixes:
    • Printf/fprintf format specifiers in pangen2.c, pangen3.c, tl_cache.c, and tl_main.c
    • Null pointer guards in pangen7.c, sched.c, structs.c, and tl_cache.c

Verification

  • Clean build (make clean && make) completed with 0 errors and 0 compiler warnings.
  • All tests and verification steps pass.

bivex added 13 commits August 9, 2026 22:07
- Fix potential buffer overflow and bounds check in main.c (preprocess)
- Fix termios c_lflag bitmask truncation on 64-bit platforms in mesg.c
- Fix potential null pointer dereferences in pangen2.c, pangen3.c, and run.c
- Fix undefined behavior in 64-bit bit shift operations (1UL<<j) in pangen6.c
- Fix EVAL AST node child type check logic in pangen6.c
- Fix code formatting ambiguity in pangen7.c
- Fix potential division by zero modulo in run.c
- Add array bounds guards for string operations in guided.c, msc_tcl.c, and structs.c
- Fix sizeof(IArg_cont[IArgno]) target buffer in spinlex.c
- Fix block scope formatting in spinlex.c
- Declare alldone(int) with noreturn attribute and fix comparison logic in main.c
- Guard NULL pointers in eligible() in pangen5.c
- Clean up redundant pointer checks in flow.c and mesg.c
- Remove redundant loop condition in pangen1.c
- Add fallthrough annotations, simplify boolean logic, and remove dead assignment in pangen2.c
- Remove unreachable code after fatal() in sym.c
- Parenthesize assignment and ternary operator expression in tl_mem.c
…rmatting notes

- Explicitly cast int/char arguments to match fprintf format specifiers in pangen2.c and pangen3.c
- Add NULL pointer checks in claim_has_accept() in pangen7.c
- Guard pointer dereferences in getlocal() and setlocal() in sched.c
- Guard NULL pointers when building struct nodes in structs.c
- Guard NULL pointers in dupnode() and isequal() in tl_cache.c
- Cast memory size arguments to long for printf formatting in tl_cache.c and tl_main.c
…n.c, and condition in run.c

- Make NextOpt static 2D array indexed by Level in dstep.c to avoid storing dangling stack pointer
- Replace debug assertions with explicit runtime bounds checks for command-line arguments in main.c to prevent buffer overflows from tainted argv data
- Remove redundant e->n check in run.c
…, emstrdup helper, memset zero loop

- emalloc() now routes all allocations ≤256 bytes through a 256KB bump-pointer arena,
  eliminating per-object malloc() overhead and improving cache locality of small objects
- emstrdup() replaces scattered emalloc(strlen)+strcpy patterns with a single memcpy call
- Symbol and Ordered nodes now allocated from dedicated 512-slot chunk pools in sym.c,
  reducing malloc calls during symbol table construction by 512x
- disambiguate() precomputes combined strlen before emalloc to avoid double traversal
- tl_mem.c: replaced manual per-word zeroing loop with a single SIMD-eligible memset call
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

Successfully merging this pull request may close these issues.

1 participant