Old 3rd April 2009, 16:37   #1
silo5
Junior Member
 
Join Date: Mar 2009
Posts: 16
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
PHP Code:
!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
PHP Code:
Global Const $WM_SETTINGCHANGE 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" _

silo5 is offline   Reply With Quote
Old 3rd April 2009, 16:57   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,150
*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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd April 2009, 18:59   #3
silo5
Junior Member
 
Join Date: Mar 2009
Posts: 16
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?
silo5 is offline   Reply With Quote
Old 3rd April 2009, 21:09   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,150
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

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th April 2009, 06:45   #5
silo5
Junior Member
 
Join Date: Mar 2009
Posts: 16
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.
silo5 is offline   Reply With Quote
Old 4th April 2009, 14:07   #6
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Tested on Vista Home Premium SP1, both nsExec and ExecDos worked correct. IMHO ping is simple test CLI application
code:
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.
Takhir is offline   Reply With Quote
Old 4th April 2009, 14:55   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,150
Quote:
Originally posted by silo5
Thanks for testing it! Are you on XP, which version?
XP SP2

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th April 2009, 00:36   #8
AaronLS
Senior Member
 
Join Date: Mar 2008
Posts: 129
@silo, What options are you using when you compile your AutoIt script?
AaronLS is offline   Reply With Quote
Old 6th April 2009, 18:33   #9
silo5
Junior Member
 
Join Date: Mar 2009
Posts: 16
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.
silo5 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump