Archive: nsExec hangs (reproducible)


nsExec hangs (reproducible)
  Script compiled with v2.44 running on WinXP SP3 hangs executing nsExec::ExecToStack (and ExeDos).
Necessary conditions include:
- custom page
- ExecToStack is executed in the custom page show function
- the executed program broadcasts a windows SetNonClientMetrics message.

Below you can find two scripts that reproduce this problem.
The second script is written in AutoIt3, it just broadcasts the message.
The first script is NSIS, it execs once in .onInit, which demonstrates that there is no failure (because it's outside the custom page). Then it execs in the custom page show function where it hangs.
You should be seeing exactly four message boxes, but you will actually see only three, one before and one after exec in .onInit, and one before exec in the show function. Then you need to kill _prog.exe which hangs in the background.

_bug.nsi

!include "MUI2.nsh"


>AutoCloseWindow false
WindowIcon on
XPSTYLE on

Name "_bug"
>OutFile "_bug.exe"
>Caption "_bug"

>VIProductVersion "1.0"
>Var program

Page custom Show Leave ""

>!insertmacro MUI_LANGUAGE "English"

>!macro _RunProgram
MessageBox mb_ok "in function ${__FUNCTION__} line ${__LINE__}..."
nsExec::ExecToStack $program
Pop$0
MessageBox mb_ok "in function ${__FUNCTION__} line ${__LINE__} exec status was $0"
>!macroend
>!define RunProgram `!insertmacro _RunProgram`

Function Show
${RunProgram}
>FunctionEnd

>Function Leave
FunctionEnd

>Function .onInit
InitPluginsDir
strcpy $program "$EXEDIR\\_prog.exe"
${RunProgram}
>FunctionEnd

Section
SectionEnd
>
_prog.au3

0x1A

>Global Const $HWND_BROADCAST = 0xFFFF
>Global Const $SPI_SETNONCLIENTMETRICS = 42

DllCall
("user32.dll", "int", "SendMessage", _
"hwnd", $HWND_BROADCAST, _
"uint", $WM_SETTINGCHANGE, _
"wparam", $SPI_SETNONCLIENTMETRICS, _
"str", "WindowMetrics" _
>)

*SendMessage is a built-in nsis command, why not just use that?

*you might want to try '"$EXEDIR\_prog.exe"'

*Can AutoIt even produce console programs?


The point of my post was to provide some sure way to reproduce this problem, which might even be an NSIS bug. I say might -- only the NSIS developers could say more.

After trimming down all the fat to make the example crispy, it looks obviously artificial, but I can assure you that it is a real problem.

I read other postings where people were reporting obscure issues with nsExec, but no clear ways to reproduce them. Maybe reproduce this problem could lead to solving other people's problems?

Using SendMessage in my installer isn't the point. I've just tried to categorize one type of application which fails with nsExec.

I don't know how to answer your question about AutoIt3. I don't know AutoIt3. This is the first time I use it. Does it matter?


I can't reproduce this problem, I get all 4 message boxes (NSIS 2.44, random autoit3 version)

You need to come up with a better example, a SendMessage broadcast can lock up if there is a window in your system that is not processing messages


Thanks for testing it! Are you on XP, which version? This example locks on two different XP boxes here. I want to test it again in a VM, so I can pair down running processes.


Tested on Vista Home Premium SP1, both nsExec and ExecDos worked correct. IMHO ping is simple test CLI application

strcpy $program "ping -n 2 localhost"
should give one second delay. Also might be good to test your sample with ExecWait/Exec first - may be something happens in CLI window. autoit3 might just hang (as Anders already wrote). Or might wait for user input. Earlier we had reports about nsExec hangs only.

Originally posted by silo5
Thanks for testing it! Are you on XP, which version?
XP SP2

@silo, What options are you using when you compile your AutoIt script?


AaronLLS, I let SciTE compile it, using whatever are the default compiler options in the standard Scite4AutoIt distribution. I'll be happy to be more precise if you tell me where to look. I really don't know AutoIt. Thanks.