why 7z.exe can not uncompress all the zip file in some windows 2008 R2?

2014-07-09
2014-07-09
    1. in our own office, the test application(stress test tool with 7z.exe) can run well.
    2. in customer's OS, the same application can not run well with the error code 2.
    3. The two OS is Win2008 64bit R2 SP1.
    4. Does the 7z.exe rely on any OS file?

    The test tool source code as below,

    include "stdafx.h"

    include <Windows.h>

    include <string>

    include "DebugHelp.h"

    using namespace std;

    bool InitalPUDir(string& sPrintUsagePath)
    {
    bool IsResult = false;
    HKEY hKey;

    //
    LPCTSTR SubKey = "SOFTWARE\\PrintUsage";
    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SubKey, 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS)
        return false;
    
    //
    DWORD m_dwCount = 0;
    if (RegQueryValueEx(hKey, "InstallPath", 0, NULL, NULL, &m_dwCount) == ERROR_SUCCESS)
    {
        char* szValueDate = (char *)malloc(m_dwCount + 1);
        if (RegQueryValueEx(hKey, "InstallPath", 0, NULL, (LPBYTE)szValueDate, &m_dwCount) == ERROR_SUCCESS)
        {
            sPrintUsagePath = szValueDate;
            IsResult = true;
        }
        free(szValueDate);
    }
    RegCloseKey(hKey);
    return IsResult;
    

    }

    void UnZipThread(int iIndex)
    {
    string sPrintUsagePath;
    InitalPUDir(sPrintUsagePath);
    string sPath;
    sPath = sPrintUsagePath + "\bin\UnZip\X86\7z.exe

    ";

    char splFile[MAX_PATH] = "";
    
    sprintf(splFile,"C:\\7zTestFile\\%d.xps",iIndex+1);
    string sXpsPath = splFile;
    
    int nPos1 = sXpsPath.rfind("\\");
    int nPos2 = sXpsPath.rfind(".");
    
    int nFindDo = sXpsPath.rfind('.');
    string sTargetPath = sXpsPath.substr(0,nFindDo);
    
    CLogShow cLog;
    strcpy(cLog.m_strLogName,sXpsPath.substr(nPos1,nPos2-nPos1).c_str());
    strcpy(cLog.m_strLogPath,"C:\\7zLog");
    
    string params = "\"" + sPath + "\" x ";
    params += "\"" + sXpsPath + "\" -o\"" +sTargetPath + "\"";
    
    cLog.Log("params:%s",params.c_str());
    
    PROCESS_INFORMATION pii;
    STARTUPINFO sii;
    memset(&sii,0,sizeof(sii));
    sii.cb=sizeof(sii);
    sii.wShowWindow=SW_HIDE;
    sii.dwFlags=STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
    cLog.Log("Begin create process");
    BOOL bResult = CreateProcess(NULL,(LPSTR)params.c_str(),NULL,NULL, TRUE,NULL,NULL,NULL,&sii,&pii);
    if (bResult)
    {
        cLog.Log("Create process OK, WaitForSingleObject");
        WaitForSingleObject(pii.hProcess, INFINITE);
    
        unsigned long Result; 
        cLog.Log("GetExitCodeProcess");
        GetExitCodeProcess(pii.hProcess, &Result);
        if (Result == 0)
        {
            cLog.Log("Exit Code is 0");
        }
        else
        {
            char ErrorCode[10] = {0};
            _itoa_s(Result, ErrorCode, 10, 10);
            string sErrorCode = ErrorCode;
            string slog = "UnZip Xps File Error,Exit Code is " + sErrorCode ;
            cLog.Log(slog.c_str());
        }
    
    }
    else
    {
        cLog.Log("Create process failed");
    }
    CloseHandle( pii.hProcess );
    CloseHandle( pii.hThread );
    

    }

    int _tmain(int argc, _TCHAR argv[])
    {
    DWORD dwThreadId[100];
    HANDLE hThrd[100] = {NULL}; // thread handle
    for (int i = 0;i < 100;i ++)
    {
    hThrd[i] = (HANDLE)CreateThread(NULL,
    0,
    (LPTHREAD_START_ROUTINE)UnZipThread,
    (void
    )i,
    0,
    &dwThreadId[i]);
    Sleep(100);
    }
    WaitForMultipleObjects(100,hThrd,0,INFINITE);
    return 0;
    }

     
    Last edit: jimmy_wei_84589272 2014-07-09
  • Add notes: in the customer's OS, only parts of files in the zip can be uncompressed.

     
  • Igor Pavlov
    Igor Pavlov
    2014-07-09

    7z.exe uses also 7z.dll

    Do you start 100 program copies to extract archives?
    Maybe it's the problem.

     
    • yes, i create 100 threads to createProcess to call 7z.exe!

      i can not understand what the problem is...and could you please share your advice?

       
    • Hi,

      i want to create 100 threads to call 7z.dll instead, but there is no document to describe the interface......

       
  • Igor Pavlov
    Igor Pavlov
    2014-07-09

    Maybe 100 copies is too big load for your system?

    Why do you need 100 threads?
    Try 1 thread.
    Try 10 threads.

     
    • That is a test tool, and i need test with big stress to find if the issue due to muti-thread. In my software, i create muti-thread to make the process more efficient.

      Now i update 7z.exe to version 9.22 bata, and the issue still exist.

      Can 7z.exe support muti-thread createprocess?

      And could i know if 7z.exe is related on any system file? i can check them on customer's OS.

       
  • Igor Pavlov
    Igor Pavlov
    2014-07-09

    7z.exe uses msvcrt.dll.
    But I don't think that it's the problem.

    I suppose that system just doesn't like 100 applications running same time.
    Maybe there is some resource quota.

    How many files do you have inside xps file?

     
    • Thanks!

      our software is muti-thread, but i do not think the thread count would be more than 10 at a same time...

       
      Last edit: jimmy_wei_84589272 2014-07-09