Talk:ExecDos plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Stack issues confirmation)
Line 76: Line 76:


'''Workaround''': When using /DETAILED, Pop to check the exit code, then Pop again to clear out the extra value.  I have not checked the behavior of /DETAILED /ASYNC.
'''Workaround''': When using /DETAILED, Pop to check the exit code, then Pop again to clear out the extra value.  I have not checked the behavior of /DETAILED /ASYNC.
I do not see this same behavior using any of the nsExec functions.


[[User:66.150.169.146|66.150.169.146]] 21:30, 6 November 2008 (UTC)
[[User:66.150.169.146|66.150.169.146]] 21:30, 6 November 2008 (UTC)

Revision as of 21:36, 6 November 2008

Possible stack corruption

I believe there is a problem with ExecDos corrupting the stack, or corrupting global variables:

Function DatabaseScriptExecuted
	; Stack: <Script.sql> <MyDB> <localhost> <C:\CMDSQL.EXE>
	
	MessageBox MB_OK "$0   $1   $2   $3   $4   $5"
	; Displays: "1422944   0001_TableExists.sql   True   0   1"
	
	Exch $3 ; Database script filename
	; Stack: <Old_$3> <MyDB> <localhost> <C:\CMDSQL.EXE>
	
	Exch
	; Stack: <MyDB> <Old_$3> <localhost> <C:\CMDSQL.EXE>

	Exch $2 ; Database name
	; Stack: <Old_$2> <Old_$3> <localhost> <C:\CMDSQL.EXE>

	Exch 2
	; Stack: <localhost> <Old_$3> <Old_$2> <C:\CMDSQL.EXE>

	Exch $1 ; Database host
	; Stack: <Old_$1> <Old_$3> <Old_$2> <C:\CMDSQL.EXE>

	Exch 3
	; Stack: <C:\CMDSQL.EXE> <Old_$3> <Old_$2> <Old_$1>

	Exch $0 ; SQLCMD.EXE path
	; Stack: <Old_$0> <Old_$3> <Old_$2> <Old_$1>

	Push $4
	; Stack: <Old_$4> <Old_$0> <Old_$3> <Old_$2> <Old_$1>

	Push $5
	; Stack: <Old_$5> <Old_$4> <Old_$0> <Old_$3> <Old_$2> <Old_$1>
	
	ExecDos::exec /DETAILED /TIMEOUT=20000 '"$0" -S $1 -d $2 -Q "select count(*) from dbo.DatabaseScript where ScriptFilename = $\'$3$\'" -o "$PLUGINSDIR\DatabaseScriptExecuted.out"' '' ''
	Pop $4 ; Pop the result off the stack first, before popping rest of saved global variables
	Pop $5
	Pop $4
	Pop $0
	Pop $3
	Pop $2
	Pop $1
	MessageBox MB_OK "$0   $1   $2   $3   $4   $5"
	; Displays: "0   True   0   1422944   1"

Note that if I move the block of script that pops my saved global variables and the message box to BEFORE the call to ExecDos::exec, the global variables are the same as when the function was entered.

It's also interesting to note that nsExec::exec also appears to have this problem.

visualcsharpcoder "at" hotmail dawt com if you want to email me about this problem.

Stack issues: confirmed

Corruption is a strong word: it looks like ExecDos::exec /DETAILED just pushes an extra empty value on the stack:

Name "Test"
OutFile "Test.exe"

Section "Foo"
  Dumpstate::debug
  ; Stack: empty
  ExecDos::exec "c:\windows\system32\ping.exe 127.0.0.1" "" ""
  Dumpstate::debug
  ; Stack: "0"
  ExecDos::exec /DETAILED "c:\windows\system32\ping.exe 127.0.0.1" "" ""
  Dumpstate::debug
  ; Stack: "0", "", "0"
  ; Expected: "0", "0"
SectionEnd

Workaround: When using /DETAILED, Pop to check the exit code, then Pop again to clear out the extra value. I have not checked the behavior of /DETAILED /ASYNC.

I do not see this same behavior using any of the nsExec functions.

66.150.169.146 21:30, 6 November 2008 (UTC)


Timeouts

TIMEOUT TOTAL execution time, milliseconds, for example /TIMEOUT=10000. Default is big enough. Short timeouts may cause app to

be terminated.




And how this Default big is?


An example showing how to redirect the output to the main log window would be great!