Skip to content

C library: syscall#8925

Draft
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:fix-7646-syscall
Draft

C library: syscall#8925
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:fix-7646-syscall

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

Fixes: #7646

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

- Implements syscall() function model as requested in issue diffblue#7646
- Delegates to existing models where available (read, write, open, close, etc.)
- Provides safe overapproximation for unmodeled syscalls
- Includes inline models for dup, lseek, getpid, getuid, and related syscalls
- Adds comprehensive test suite with 3 test cases covering basic functionality,
  error handling, and realistic usage scenarios
- Includes detailed documentation and implementation summary

Addresses: diffblue#7646
Follows approach from: model-checking/kani#2284
As requested by @tautschnig in PR comment #3520785346, this refactors
the inline model implementations in syscall.c to follow CBMC library
function standards and structure.

Changes made:
- Extracted 10 inline models into separate CBMC library functions
- Created dup.c with dup(), dup2(), dup3() implementations
- Created lseek.c with lseek() implementation
- Created process_info.c with getpid(), getuid(), getgid(), geteuid(), getegid(), gettid()
- Updated syscall() function to delegate to these library functions
- Reduced syscall.c complexity by ~150 lines
- All functions now follow standard CBMC library patterns

Benefits:
- Improved maintainability and code organization
- Functions can be reused independently of syscall()
- Consistent with existing CBMC library structure
- Better separation of concerns
- Simplified syscall dispatch logic

All existing tests continue to pass. The refactoring is fully
backward compatible with no change to external interfaces.
@tautschnig tautschnig self-assigned this Mar 29, 2026
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.

Add a model of syscall to the C library

1 participant