Skip to content

Fix crash on first launch: initialize m_pLogView - #33

Merged
ghirpara merged 1 commit into
bluemoonfoundry:masterfrom
abrady:fix/uninitialized-logview-crash
Aug 14, 2026
Merged

Fix crash on first launch: initialize m_pLogView#33
ghirpara merged 1 commit into
bluemoonfoundry:masterfrom
abrady:fix/uninitialized-logview-crash

Conversation

@abrady

@abrady abrady commented Aug 14, 2026

Copy link
Copy Markdown

Summary

DzScriptServerPane::m_pLogView is never initialized before the constructor calls appendLog(), so the first launch on a machine with no token file dereferences an uninitialized pointer and takes DAZ Studio down during startup.

Crash

DAZStudio.exe caused ACCESS_VIOLATION in module "Qt6Widgets.dll"
at 0033:00000000B010B5E5, QTextEdit::append()+21 byte(s)

Studio's log ends at Creating Pane Manager..., and the stack has three dsp_DazScriptServer-ds6-windows.dll frames directly beneath QTextEdit::append.

Environment: DAZ Studio 6 beta, stock Qt 6.10.3.0, Qt6Core5Compat.dll present, Windows 11, prebuilt dsp_DazScriptServer-ds6-windows.dll from release v2.8.0. Not an ABI mismatch — that Qt matches the aqt install-qt windows desktop 6.10.3 win64_msvc2022_64 pin in build-windows.yml.

Cause

m_pLogView (include/DzScriptServerPane.h:310) is the only widget pointer missing from the constructor's initializer list — m_pServer, m_pAsyncMgr, m_pCleanupTimer, m_pEventBroker and m_pPersistentScript are all there.

The constructor calls appendLog() at src/DzScriptServerPane.cpp:240, roughly 180 lines before m_pLogView = new QTextEdit(this) at line 424. The guard in appendLog:

if (!m_pLogView)
    return;

tests an indeterminate value, passes on non-zero stack garbage, and line 783 dereferences it.

Why it reproduces only once

AuthenticationService::loadOrGenerateToken populates outMessages only when there is no valid token file — with one, it early-returns with the list empty, the loop never runs, and appendLog is never reached. (On Windows the permissions-warning branch is #ifndef _WIN32, so a valid token means zero messages.)

The crashing run still writes the token first, since saveToken precedes the message that kills it — so the bug disarms itself and relaunching just works. A maintainer who already has a token cannot reproduce it, and it is invisible wherever the garbage happens to be zero.

Workaround for anyone hitting this: create ~/.daz3d/dazscriptserver_token.txt containing any ≥32-character line before first launch.

Fix

One line, placed to match declaration order (m_pEventClientsLabel is line 309, m_pLogView line 310).

Worth a follow-up audit: the other widget pointers (m_pStartBtn, m_pStopBtn, m_pAutoStartCheck, …) are uninitialized on the same path. They aren't dereferenced this early today, so this PR leaves them alone.

Testing

Reproduced the crash on a clean machine, applied the workaround to confirm the token-file dependency, and verified the plugin then loads and runs normally — Running on 127.0.0.1:18811 (Protected), with scene queries, morph reads, visibility toggles and async renders all working against DS6.

DzScriptServerPane's constructor calls appendLog() for each message from
AuthenticationService::loadOrGenerateToken, which happens ~180 lines before
m_pLogView is assigned in the UI setup. m_pLogView was the only widget
pointer missing from the initializer list, so appendLog()'s

    if (!m_pLogView) return;

guard tested an uninitialized value, passed on non-zero stack garbage, and
dereferenced it.

loadOrGenerateToken only emits messages when there is no valid token file,
so this reproduces exactly once per machine -- on the very first launch,
before any token exists. The crashing run still writes the token first
(saveToken precedes the message), so the bug disarms itself and a relaunch
succeeds, which is why it is easy to miss. It is also invisible wherever the
uninitialized value happens to be zero.

Observed on DAZ Studio 6 (Qt 6.10.3, Windows 11) with the v2.8.0 DS6 build:
ACCESS_VIOLATION at QTextEdit::append()+21, three frames of
dsp_DazScriptServer-ds6-windows.dll beneath it, with Studio's log ending at
"Creating Pane Manager...".
@ghirpara
ghirpara merged commit 425aa8d into bluemoonfoundry:master Aug 14, 2026
3 checks passed
@ghirpara

Copy link
Copy Markdown
Member

@abrady Merged. Good catch!

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.

3 participants