SFX Issue - SaveSelfExtractor gets stuck sometimes at ~285MiB

Dec 4, 2013 at 2:57 PM
Edited Dec 4, 2013 at 3:03 PM
Hi,

I recently tried to automate an SFX creation with DotNetZip and PowerShell. Procedure is as following:
  1. Loading Ionic.Zip.dll
  2. Reading in configuration from a file
  3. Validating configuration input
  4. Following you will find the proceeding relevant code snippets:
   #<...> defines where I cut some code
   #<some initializing variable setting>
        $private:dll = "$private:currentPath\Ionic.Zip.dll"
        [void][System.Reflection.Assembly]::LoadFrom($private:dll)
   #<Steps 2-3>
        try {
            $private:zipfile =  new-object Ionic.Zip.ZipFile
        } catch [Exception] {
   #<handling exception>
        }
        For ($i = 0; $i -le  ($conffile.SourceFiles0.count - 1); $i++)
        {
            $private:addFile = $conffile.Strings.Item("FILE$i")
   #<doing some irrelevant stuff>
            try {
                $private:zipfile.AddFile("$private:addFile")
            } catch [Exception] {
   #<handling exception>
            }
        }
        try {
            $private:sfxOptions = new-object Ionic.Zip.SelfExtractorSaveOptions
        } catch [Exception] {
   #<handling exception>
        }
        try {
            $private:sfxOptions.Flavor = [Ionic.Zip.SelfExtractorFlavor]::WinFormsApplication
        } catch [Exception] {
   #<handling exception>
        }
        $private:sfxOptions.DefaultExtractDirectory = "%USERPROFILE%\AppData\Local\Temp\"
        $private:sfxOptions.PostExtractCommandLine = $conffile.Strings.AppLaunched
        $private:sfxOptions.SfxExeWindowTitle = $conffile.Strings.FriendlyName
        $private:sfxOptions.RemoveUnpackedFilesAfterExecute = $true
        $private:sfxOptions.Quiet = 1
        $private:zipfile.CompressionLevel = 0
        try {
   #__this is where it gets stuck - not throwing any exception__
            $private:zipfile.SaveSelfExtractor($conffile.Strings.TargetName, $private:sfxOptions)
        } catch [Exception] {
   #<handling exception>
        }
        try {
            $private:zipfile.Dispose()
        } catch [Exception] {
   #<handling exception>
        }
With correct input data this never throws an exception.
Running this the first time always succeeds, but when running it again, there is a chance, that it will already get stuck at attempt 2. Most count of successful attempts I ran after each other were at a count of 4, I never created 5 times a successful SFX after each other.
My repeating tests had always exactly the same input data and files.
After it gets stuck, I can kill the process to retry, but it will get stuck over and over until I restart the computer. The pretty strange thing is the sporadically stucking with a continuing stucking afterwards at something between 285MiB and 286MiB.

My idea already was some opened filehandle within the .dll but afaik that should get closed after killing a process.
I did not see any relevant errors by watching it with procmon.exe (Windows Tool: Process Monitor).

CPU usage of powershell.exe is about 95% during the process, when it gets stuck it decreses to 0%.
Memory usage is about 700MiB with lots of free space left to use.
HDD I/O is on its limit while writing - which seems pretty normal when copying files.

Do you have any ideas what could cause that problem?

Thank you in advance.
Kind Regards.