Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • O OSKernel2026-StellaOS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • StellaOS
  • OSKernel2026-StellaOS
  • Merge requests
  • !49

fix: remove exec() stack alignment gap between sp and argc

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged StellaOS requested to merge merge_6.8 into main Jun 08, 2026
  • Overview 0
  • Commits 16
  • Pipelines 0
  • Changes 164

The post-argc user_sp -= user_sp % 16 created an 8-byte padding gap between the stack pointer and argc on the user stack. glibc's RISC-V _start reads argc from *sp and computes argv as sp+8, so the gap caused:

  1. argc read as 0 (the padding byte) instead of the actual count
  2. argv offset 8 bytes too low
  3. __libc_start_main computed a wrong auxv pointer (landing on envp NULL instead of AT_BASE)
  4. glibc init function 0x11d1e8 received *a0=0 (AT_NULL), took early return, and never wrote the function pointer at 0x1b7bc0
  5. Subsequent deref of that NULL function pointer → LoadPageFault(1)

The alignment is unnecessary because glibc's _start already does andi sp, sp, -16 to re-align the stack before calling into C code. This happened to work for argc=1 (basic tests) because the arithmetic coincidentally left no padding.

Also:

  • syscall: log tid for thread-level debugging; return ENOSYS instead of panicking on unknown syscall IDs
  • from_elf: pre-initialize dtv array in the main-thread TCB so glibc can find _dl_static_dtv during TLS bootstrap
  • initproc: switch to busybox for debugging
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: merge_6.8