Skip to content

Fixed issue 148 draw context stack overflow#158

Merged
fdesbiens merged 2 commits into
eclipse-threadx:devfrom
fdesbiens:fix/issue-148-draw-context-stack-overflow
Jun 1, 2026
Merged

Fixed issue 148 draw context stack overflow#158
fdesbiens merged 2 commits into
eclipse-threadx:devfrom
fdesbiens:fix/issue-148-draw-context-stack-overflow

Conversation

@fdesbiens

Copy link
Copy Markdown
Contributor

No description provided.

fdesbiens and others added 2 commits June 1, 2026 17:23
All callers of _gx_canvas_drawing_initiate() must check the return
value before calling draw functions or _gx_canvas_drawing_complete().
When GX_DRAW_NESTING_EXCEEDED is returned the context stack is NOT
pushed, so calling _gx_canvas_drawing_complete() corrupts the outer
context's nesting counter.

Fix pattern (matching _gx_widget_children_draw.c reference impl):
  status = _gx_canvas_drawing_initiate(...);
  if (status == GX_SUCCESS) { draw(); _gx_canvas_drawing_complete(); }
  else if (status == GX_NO_VIEWS) { _gx_canvas_drawing_complete(); }
  // else: stack overflow or invalid memory -- do nothing

Files fixed:
- gx_animation_start.c
- gx_animation_drag_tracking_start.c
- gx_multi_line_text_view_text_draw.c
- gx_multi_line_text_input_draw.c
- gx_rich_text_view_text_draw.c
- gx_single_line_text_input_draw.c
- gx_radial_progress_bar_background_draw.c (GX_BRUSH_ALPHA_SUPPORT path)
- gx_widget_block_move.c
- gx_system_canvas_refresh.c (partial and non-partial paths)
- gx_system_error_process.c (Copilot attribution only; functional changes via eclipse-threadx#156)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…k overflow

Tests that _gx_canvas_drawing_initiate() overflow does not corrupt the
draw context state:

1. Overflow detection: GX_DRAW_NESTING_EXCEEDED returned at max depth
   (GX_MAX_CONTEXT_NESTING = 8 levels).
2. No state corruption: gx_canvas_draw_nesting and
   _gx_system_current_draw_context are unchanged after overflow.
3. Caller regression (_gx_widget_block_move): does not corrupt nesting
   counter or context pointer when overflow occurs at max depth. This
   would fail against the pre-fix code, which called
   _gx_canvas_drawing_complete() unconditionally.
4. Full unwind: gx_canvas_draw_nesting == 0 and context pointer == NULL
   after GX_MAX_CONTEXT_NESTING calls to gx_canvas_drawing_complete().
5. Recovery: a fresh drawing initiate/complete pair succeeds after full
   unwind.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@fdesbiens fdesbiens merged commit 8a35f69 into eclipse-threadx:dev Jun 1, 2026
1 check passed
@fdesbiens fdesbiens deleted the fix/issue-148-draw-context-stack-overflow branch June 1, 2026 21:29
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