Skip to content

Fix the "--enable-optimization Seg Fault"#96

Open
Lightning11wins wants to merge 1 commit into
masterfrom
fix-optimization
Open

Fix the "--enable-optimization Seg Fault"#96
Lightning11wins wants to merge 1 commit into
masterfrom
fix-optimization

Conversation

@Lightning11wins
Copy link
Copy Markdown
Contributor

Add code to disable CXSS_DEBUG_CONTEXTSTACK when the USING_OPTIMIZATION flag is defined. The checks made by context stack debugging can cause seg-faults if the compiler applies optimizations. With this PR, such checks are now disabled, allowing pages to load successfully again with --enable-optimization in use.

@Lightning11wins Lightning11wins self-assigned this Apr 7, 2026
@Lightning11wins Lightning11wins added bug ai-review Request AI review for PRs. labels Apr 7, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 7, 2026

Greptile Summary

This PR fixes a segfault that occurs when Centrallix is compiled with --enable-optimization by disabling the CXSS_DEBUG_CONTEXTSTACK macro in that build configuration. The debug code uses __builtin_return_address(1) to detect mismatched cxssPushContext/cxssPopContext calls, which is unreliable (and can return garbage or NULL) when compiler optimizations are applied, causing the crash.

Confidence Score: 5/5

Safe to merge — the core fix is correct and the only finding is a minor style concern about include ordering.

The fix correctly disables unreliable __builtin_return_address(1) debug checks under optimization. One P2 comment about config.h placement after system headers, which is consistent with an existing pattern in the codebase and does not affect correctness of this change.

No files require special attention.

Important Files Changed

Filename Overview
centrallix/include/cxss/cxss.h Adds #ifdef HAVE_CONFIG_H / #include "config.h" and conditionally disables CXSS_DEBUG_CONTEXTSTACK when USING_OPTIMIZATION is defined, preventing seg-faults from unreliable __builtin_return_address(1) under optimization; config.h is included after system headers rather than first.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Compile centrallix] --> B{--enable-optimization?}
    B -- Yes --> C[USING_OPTIMIZATION defined in config.h]
    B -- No --> D[USING_OPTIMIZATION not defined]
    C --> E[CXSS_DEBUG_CONTEXTSTACK = 0]
    D --> F[CXSS_DEBUG_CONTEXTSTACK = 1]
    E --> G["CallerReturnAddr field NOT in CxssCtxStack struct\n__builtin_return_address checks DISABLED"]
    F --> H["CallerReturnAddr field IN CxssCtxStack struct\n__builtin_return_address checks ENABLED"]
    G --> I["cxssPushContext / cxssPopContext run safely"]
    H --> J["Push/Pop mismatch detection active\n(debug builds only)"]
Loading

Reviews (2): Last reviewed commit: "Add code to disable CXSS_DEBUG_CONTEXTST..." | Re-trigger Greptile

@Lightning11wins Lightning11wins changed the title Fix Seg Fault When --enable-optimization Is Used Fix the "--enable-optimization Seg Fault" Apr 7, 2026
@Lightning11wins
Copy link
Copy Markdown
Contributor Author

This PR is cleared for human review.

@Lightning11wins Lightning11wins added the size: trivial Easy to review, probably ~100 lines or fewer. label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request AI review for PRs. bug size: trivial Easy to review, probably ~100 lines or fewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant