Conversation
This consolidates differential gate that compiles the bolknote/violawww
browser against lib{x11,Xt,Xpm,Xmu}-compat + bundled Motif.
Memory safety and contract:
- xCopyArea raster-op fallback for non-GXcopy/masked planeMask:
read-modify-write through SDL_RenderReadPixels with calloc-backed
pixel buffers, viewport-offset translation on read rects, source
read before destination renderer is resolved (GET_RENDERER can
lazily switch active SDL target).
- subtractSegment uses caller-provided scratch buffer and int64
extents; renderFillRectClipByChildren bounded against SIZE_MAX wrap.
- font.c NULL string guards; decodeChar2bString rejects negative
counts and caps allocation; XDrawString16 double-free removed;
XmbTextPerCharExtents rejects negative buffer size; Xmb/Xutf8
TextEscapement use int64 fallback; text extents clamp to short.
- decodeString stripped to bounded copy + NUL-terminate.
- XListFonts returns caller-owned strdup'd entries with NULL
sentinel; XFreeFontNames walks-and-frees; isSupportedFontFileName
case-insensitive.
- XGeometry / XWMGeometry pixel math via new satMulAdd
(__builtin_mul_overflow / __builtin_add_overflow) with
clampInt64ToInt narrowing. Anchor logic preserves upstream X.org
semantics: default-width anchoring when user spec has no position,
merged-width anchoring when user position is set.
- XCopyArea int64 extent guards before SDL_Rect math.
- XDoubleToFixed clamps representable range; NaN returns 0.
- XPutImage stride validation: non-negative bytes_per_line plus a
minimum row size for every format that dereferences image->data
(ZPixmap any bpp, XYBitmap, XYPixmap).
Pointer + grab contract:
- XQueryPointer NULL-checks every output, type-checks window,
reports pressed-button bits in mask_return.
- XWarpPointer containment and warp coord math in int64.
- XGrabPointer returns BadWindow / GrabNotViewable / AlreadyGrabbed
/ GrabInvalidTime (CARD32 signed-delta against SDL_GetTicks,
tick-wrap safe).
- XGrabButton replaces existing grab on (button, modifiers, window)
match instead of leaking duplicates; passive grabs are now released
in destroyWindow so XID reuse cannot route events through a stale
grab entry.
- Grab cursor saved/restored on ungrab; activatePassiveButtonGrab
uses new getContainingWindow helper.
Window show timing:
- Top-level SDL_Windows are created with SDL_WINDOW_HIDDEN so the
user never sees an empty frame; XMapWindow renders content first
and only then calls SDL_ShowWindow. Reparent-into-top-level also
shows after realize since it bypasses XMapWindow.
Concurrency:
- putBackEventsLock, trackedDisplaysLock, activePointerWindowLock
(the last shared by activePointerWindow + pointerButtonState).
pointerButtonStateSnapshot() snapshot helper for motion/wheel
reads; press/release writes go through the same critical section.
- putImageScratchLock with lazy SDL_AtomicLock spinlock init,
process-long lifetime, lock/unlock pair returns and accepts the
acquired SDL_mutex* handle so the lazy-init race cannot make a
thread unlock what it did not lock.
- Event pipe fds initialized to -1, closed on last display close;
dead fdopen(FILE*) leak path removed; closeEventPipe runs
unconditional last-display teardown.
Build system:
- Debug-only NULL guards on GET_WINDOW_STRUCT, GET_GC, GET_DISPLAY
via __extension__ statement expressions (release builds unchanged).
- STRICT=1 build variant adds -Werror to first-party objects only,
applied via mk/common.mk and mk/xcompat-libs.mk.
- New `differential` umbrella target runs motif-demos-check and
violawww as separate sub-makes; aggregate exit reports both
statuses on failure so one regression cannot mask the other.
- mk/violawww.mk pins the bolknote/violawww commit and fetches the
pinned sha before checkout so commit bumps stay reproducible
against a reused clone; externals/violawww/ added to .gitignore.
CI:
- ViolaWWW build step in the motif job after demo smoke checks,
with `if: !cancelled()` so a demo failure does not skip ViolaWWW
(and ccache stats).
- Build log uploaded as an artifact scoped to the violawww step's
outcome — `if: steps.violawww.outcome == 'failure'` — so a prior
motif-demos-check failure cannot attach a misleading successful
log to the artifact.
Tests:
- XDoubleToFixed NaN/saturation; XGeometry massive-value clamp via
parseable spec + huge font cell (avoids upstream XParseGeometry's
internal signed-int overflow that UBSan caught in CI); XCopyArea
INT_MAX rejection asserts BadValue via record_error; GXxor
raster-op pixel readback; XListFonts pattern-buffer alias guard;
XGrabPointer AlreadyGrabbed/BadWindow; ZPixmap XPutImage alpha
promotion; X11-pixel-color pixmap and text rendering. The
ClientMessage XSendEvent test now uses full XEvent storage so
ASan's stack-buffer-overflow check is happy with the sizeof(XEvent)
memcpy XSendEvent does on the caller buffer.
Deferred: full thread-safety beyond the four locks above (no other
shared state surfaced by reviewers); file splits for drawing.c clip
helpers and events.c pipe helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This consolidates differential test that gates the compat stack against the ViolaWWW browser. Affected Xlib surface spans XCopyArea, XGrabPointer, XQueryPointer, XWarpPointer, XGeometry/XWMGeometry, XDrawString family, XListFonts, XPutImage, XDoubleToFixed, and the SDL event/grab pipeline.
Memory safety and contract:
Pointer + grab contract:
Concurrency:
Build:
CI:
Build commands run: make, make check, make
CFLAGS_EXTRA=-DDEBUG_LIBX11_COMPAT check, make STRICT=1.
Summary by cubic
Hardened the X11 compat stack and added a
violawwwdifferential build gate to catch regressions. This improves pointer/grab correctness, drawing/font safety, window show timing, and CI reliability.Bug Fixes
XCopyAreafallback with read rect clipping; int64 bounds on copies/geometry;XPutImagestride checks with a process-long scratch lock; default opaque alpha for X11 pixels; clampedXDoubleToFixed.XDrawString16double-free, sanitizedecodeString,XListFontsreturns caller-owned lists.XQueryPointer; int64XWarpPointer; strictXGrabPointer/XGrabButtonsemantics (errors, AlreadyGrabbed, time checks), passive button grabs with cursor save/restore, release grabs on window destroy, and viewability-aware containment.XPutImagescratch; event pipe fds init to -1 and torn down on last display close.XGeometry/XWMGeometry;XRenderSetPictureTransformstub;XGrabServer/XUngrabServerare no-ops; top-level windows start hidden and are shown on map.Build and CI
STRICT=1enables warnings-as-errors for first-party code viaSTRICT_CFLAGS; debug-only NULL guards forGET_DISPLAY,GET_GC, andGET_WINDOW_STRUCT.mk/violawww.mkandmake violawwwgate pinningbolknote/violawww;.gitignoreignoresexternals/violawww/; addedmake differentialto run Motif smoke checks plusviolawww.violawwwafter Motif smoke tests, uploads logs on failure, and runs even if demos fail (if: !cancelled()).Written for commit 0e9bc42. Summary will update on new commits.