[GH-ISSUE #543] Bug: Invalid borderStyle value causes segmentation fault #145

Closed
opened 2026-03-02 23:44:53 +03:00 by kerem · 0 comments
Owner

Originally created by @beorn on GitHub (Jan 16, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/543

Originally assigned to: @msmps on GitHub.

Environment

  • macOS (Apple Silicon) - Darwin arm64
  • Bun 1.3.5
  • @opentui/core 0.1.73
  • @opentui/react 0.1.73

Description

When using an invalid borderStyle value (e.g., "round" instead of the valid "rounded"), the application crashes with a segmentation fault instead of showing an error or falling back to a default style.

Reproduction

import { createCliRenderer } from "@opentui/core";
import { createRoot } from "@opentui/react";

const renderer = await createCliRenderer();

// This crashes with segfault:
createRoot(renderer).render(
  <box border borderStyle="round" width={30} height={5}>
    <text>Invalid borderStyle crashes</text>
  </box>
);

Expected Behavior

Either:

  1. TypeScript should catch invalid values at compile time (it does, but runtime should still handle it gracefully)
  2. Runtime should throw a clear error message like "Invalid borderStyle: 'round'. Valid values are: single, double, rounded, heavy"
  3. Fall back to the default border style

Actual Behavior

Segmentation fault at address 0x10 or 0x48:

================================================================================
Bun v1.3.5 (a6ba3035) macOS Silicon

Segmentation fault at address 0x10
Segmentation fault

oh no! Bun has crashed. This indicates a bug in Bun, not your code.

Analysis

The crash occurs in the native Zig library (libopentui.dylib). The invalid borderStyle value "round" likely causes an out-of-bounds lookup in the BorderChars record which expects only: "single" | "double" | "rounded" | "heavy".

Workaround

Use only valid borderStyle values: "single", "double", "rounded", or "heavy".

Suggestion

Add input validation for borderStyle in the JavaScript layer before passing to the native Zig code:

const validStyles = ["single", "double", "rounded", "heavy"];
if (!validStyles.includes(borderStyle)) {
  console.warn(\`Invalid borderStyle "${borderStyle}", using "single"\`);
  borderStyle = "single";
}
Originally created by @beorn on GitHub (Jan 16, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/543 Originally assigned to: @msmps on GitHub. ## Environment - macOS (Apple Silicon) - Darwin arm64 - Bun 1.3.5 - @opentui/core 0.1.73 - @opentui/react 0.1.73 ## Description When using an invalid `borderStyle` value (e.g., `"round"` instead of the valid `"rounded"`), the application crashes with a segmentation fault instead of showing an error or falling back to a default style. ## Reproduction ```tsx import { createCliRenderer } from "@opentui/core"; import { createRoot } from "@opentui/react"; const renderer = await createCliRenderer(); // This crashes with segfault: createRoot(renderer).render( <box border borderStyle="round" width={30} height={5}> <text>Invalid borderStyle crashes</text> </box> ); ``` ## Expected Behavior Either: 1. TypeScript should catch invalid values at compile time (it does, but runtime should still handle it gracefully) 2. Runtime should throw a clear error message like "Invalid borderStyle: 'round'. Valid values are: single, double, rounded, heavy" 3. Fall back to the default border style ## Actual Behavior Segmentation fault at address 0x10 or 0x48: ``` ================================================================================ Bun v1.3.5 (a6ba3035) macOS Silicon Segmentation fault at address 0x10 Segmentation fault oh no! Bun has crashed. This indicates a bug in Bun, not your code. ``` ## Analysis The crash occurs in the native Zig library (`libopentui.dylib`). The invalid borderStyle value `"round"` likely causes an out-of-bounds lookup in the `BorderChars` record which expects only: `"single" | "double" | "rounded" | "heavy"`. ## Workaround Use only valid borderStyle values: `"single"`, `"double"`, `"rounded"`, or `"heavy"`. ## Suggestion Add input validation for borderStyle in the JavaScript layer before passing to the native Zig code: ```typescript const validStyles = ["single", "double", "rounded", "heavy"]; if (!validStyles.includes(borderStyle)) { console.warn(\`Invalid borderStyle "${borderStyle}", using "single"\`); borderStyle = "single"; } ```
kerem 2026-03-02 23:44:53 +03:00
  • closed this issue
  • added the
    core
    bug
    labels
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#145
No description provided.