Archive: NSDialogs::NSD_GetText intermittent failure and crash with 8192-char build


NSDialogs::NSD_GetText intermittent failure and crash with 8192-char build
  I'm running into an odd problem here where NSD_GetText will return what appears to be an empty string from an edit control (NSD_CreateText) intermittently.

I.e. on my installer's startup, where I've got an interactive feedback through an NSD_OnChange, it will very often fail.. I'll enter some gobbledygook into the edit control and suddenly - randomly - it'll start working. After that it'll tend to keep working, but every once in a while it'll break again as well and once again it returns an empty string.

I am using the 8192-character version of makensis, and this seems to be the culprit somehow; reverting to the regular build solves the issue - but creates a new one ;)

I can't share the actual installer code, but here's a sample that will replicate the behavior - albeit less severely so.

!include "MUI2.nsh"

>!include "nsDialogs.nsh"

>OutFile "test.exe"

>Page Custom test

>Var dialog
>Var editcontrol
>Var label
>Var hwnd

>Function test
nsDialogs::Create 1018
Pop $dialog

${NSD_CreateText} 0% 3% 100% 8% "Testing"
Pop $editcontrol
${NSD_OnChange} $editcontrol editchanged

${NSD_CreateLabel} 0% 12% 100% 70% "Testing"
Pop $label

nsDialogs::Show
FunctionEnd

>Function editchanged
Pop $hwnd
${NSD_GetText} $hwnd $0
${NSD_SetText} $label $0
FunctionEnd

Section
SectionEnd

>!insertmacro MUI_LANGUAGE "English"
Tests to run:
1. Enter some text. It should get replicated in the label below the edit contol.

2. Copy the text and paste it a bunch of times - eventually (at 256 characters), the label will not show the text anymore.
At this point, if you erase your text, the label may either update again or it will stay empty.
( in the standard build, you can enter well beyond 256 characters without problem. )

3. Paste your text a whole lot more - eventually, the installer will simply crash to desktop.

Unfortunately this is not exactly the same scenario as in my actual installer - as it has far less than 256 characters in it; but I'd imagine the problems are related if not the exact same in origin.

Thoughts? Thanks in advance! :)

I can't reproduce this with either builds. Can you find a scenario that's easier to reproduce?


I was hoping that was the easiest reproduction case - never fails to fail here :\

Let's try with this, though...

!include "MUI2.nsh"

>!include "nsDialogs.nsh"

>OutFile "test.exe"

>Var InstallDir

>Var dialog
>Var hwnd
>Var null

>Var NSD_InstallDir
>Var NSD_StatusLabel

Page Custom page.settings


>Function page.settings
!insertmacro MUI_HEADER_TEXT " Installation settings" " Some more text goes here..."

nsDialogs::Create 1018
Pop $dialog

${NSD_CreateLabel} 3% 3% 25% 8% "&Installation folder: "
Pop $null

${NSD_CreateText} 29% 3% 63% 8% "C:\Program Files\Test\Test 2"
Pop $NSD_InstallDir
${NSD_OnChange} $NSD_InstallDir page.settings.installdir.onchange

${NSD_CreateButton} 92% 3% 5% 8% "..."
Pop $hwnd

${NSD_CreateGroupbox} 0% 60% 100% 39% ""
Pop $null
${NSD_CreateLabel} 3% 66% 94% 31% ""
Pop $NSD_StatusLabel

nsDialogs::Show
FunctionEnd

>Function page.settings.installdir.onchange
Pop $hwnd
${NSD_GetText} $hwnd $InstallDir
MessageBox MB_OK "$$InstallDir = '$InstallDir'"
${NSD_SetText} $NSD_StatusLabel "'$InstallDir'"
>FunctionEnd


Section
SectionEnd

>!insertmacro MUI_LANGUAGE "English"
This is slightly more akin to the actual installer I'm working on - basically that's an installation path bit with browse button and whatnot, and I'm interactively checking whether the path is malformed or not, etc. That code isn't included here, but you get the idea.

Build this with NSIS 2.46 base install + makensis v2.46 NSIS_MAX_STRLEN=8192.

Upon execution, nothing particular should happen. Now add/remove text from the path. You should get a messagebox, and a status label gets updated.
On the very first character I enter, that messagebox and label shows me that the value that was retrieved with NSD_GetText appears to be empty, displaying ''. The second character is okay.

The aforementioned bits still apply, though - it intermittently fails again. Easier to test after removing the messagebox (which is just there to check whether the problem was in gettext or settext).

Without fail - the 1024-character default build works just fine even on the first character changed.