Announcement

Collapse
No announcement yet.

Problem with Replace-command

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #41
    "Garbage collection" is not pertinent to this context, sorry.

    I personally believe the problem is more rudimentary, but even though Fred has posted most of his DLL code, we are unable to run the code to try to duplicate the problem because the INC files are not provided, and we would need his large data files too, plus the calling EXE code

    The earlier "Houston..." thread never eventuated to anything so it is not particularly relevent. The only common aspect is that the code in that message appears to be related to his code in this thread - Fred may be experiencing the same problems with his particular design or implementation.

    We have no idea how his code is being called from the main executable, whether something in that code is overwriting memory used by the DLL (which may not trigger a GPF because it could be manipulating memory wholy allocated to this process), or whether it is much more fundamental.

    Until we can duplicate this problem (by running the code), resolving Fred's issue is not going to be easy.




    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #42
      Steve,
      I wrote a small test piece today using the Replace command and then
      decompiled it to see what it was doing and it just does not have any
      problems in the code. It uses the normal OLE string pool in the
      normal way so the code is in itself fine. This means it can ONLY be
      a buffering problem with the OLE string pool with the version of NT
      and service pack that you customer is using.
      If I'm not mistaken all the ole string functions are supposed to operate on
      unicode strings not ascii. Do you see where this might be a problem?

      James



      ------------------

      Comment


      • #43
        Sorry, the "sauer-kraut" forgot to extract functions needed from
        the runtime-library FOXRUN32.DLL when he published the DLL-code
        Either include this in the DLL-code or name it FoxRun32.INC

        Code:
        'code extracted from FoxRun32.DLL
        'Name the file "FOXRUN32.INC"
        'FILE WIN32API.BAS IS EQUAL TO WIN32API.INC BUT IS RENAMED TO PREVENT ACCIDENTAL
        'VERSION INCOMATIBILITIES
        '===[KONSTANTER]=================================
        %AsaVar2Pcc  = 0
        %AsaFix2Pcc  = 1
        %AsaVar2Xfp  = 2
        %AsaFix2Xfp  = 3
        '==[KONSTANTER]==================================
        %NONE   = 0
        %ASCII  = 1
        %ANSI   = 2
        %EBCDIC = 3
        '==[Översättningstabeller]=======================
        %ASC2ANS = 10
        %ASC2EBC = 11
        %ANS2ASC = 12
        %ANS2EBC = 13
        %EBC2ASC = 14
        %EBC2ANS = 15
        %ASC2ASC = 16
        %ANS2ANS = 17
        %EBC2EBC = 18
        '==[FilTyper]====================================
        %PCFIL     = 1
        %ASAFIL    = 2
        %PCCFIL    = 3
        '==[Konverteringstyper]==========================
        %PCCASC       = 30
        %PCCEBC       = 40
        %PCCASC2ASA   = 31
        %PCCASC2PCC   = 32
        %PCCASC2XFP   = 33
        %PCCEBC2ASA   = 41
        %PCCEBC2PCC   = 42
        %PCCEBC2XFP   = 43
        %PCCNOHDR     = 45
        %PCCNOHDR2PCC = 46
        %PCCNOHDR2XFP = 47
        %ASACNTVAR = 20
        %ASACNTFIX = 21
        '==[Script]=====================================
        %PcToPcc    =100
        %PcToXfp    =101
        %PcToAsa    =102
        %PcToAsaVar =1020
        %PcToAsaFix =1021
        %AsaToPcc   =200
        %AsaToXfp   =201
        %PccToPcc   =300
        %PccToXfp   =301
        %PccToAsa   =302
        %S36ToPcc   =400
        %S36ToXfp   =401
        %S36ToAsa   =402
        %VarToFix   =500
        %FixToVar   =501
        %XlateFil   =502
        %SignalFil  =503
        %MoveFil    =504
        %ZipFil     =505
        %UnZipFil   =506
        %CountPc    =510
        %CountPcc   =511
        %CountAsa   =512
        %MailFil    =600
        %MailZip    =601
        %Var2Fix    = 0
        %Fix2Var    = 1
        %XfpToXfp   = 700
        %XfpToPcc   = 701
        %XfpToAsa   = 702
        
        Function FSO_GetFileName(ByVal PathSpec$)Export As String
         Function = Mid$(PathSpec$,Instr(-1,PathSpec$,"\")+1)
        End Function
        Function FSO_AppPath()Export As String
        Local l&,Buffer$
        Buffer$=Space$(500)
            L& = GetModuleFileName(%NULL, _
                                   ByVal StrPtr(Buffer$), _
                                   ByVal Len(Buffer$))
            If L& = 0 Then Function = "":Exit Function
            Buffer$=Left$(Buffer$,L&)
            Function = FSO_GetParentFolderName(Buffer$)
        End Function
        Function FSO_GetParentFolderName(ByVal PathSpec$)Export As String
         If Instr(PathSpec$,"\")=0 Then Function="": Exit Function
         Function = Mid$(PathSpec$,1,Instr(-1,PathSpec$,"\"))
        End Function
        Function FSO_DeleteFile(ByVal FileSpec$)Export As Long
         Function = 1
         On Error Resume Next
         Kill FileSpec$
         If ErrClear > 0 Then Function = 0
        End Function
        You will need an ASA-file to be able to test this functions.
        This is a simple testprogram that create such a testfile
        and simulates the calling function from my Main Exe:
        Code:
        #Compile Exe
        #Include "Win32Api.inc"
        Type ErrResult
          ErrNr         As Long
          FilPos        As Quad
          BuffSize      As Long
          BuffPos       As Long
          FelRad        As String * 100
        End Type
        
        %NONE   = 0
        %ASCII  = 1
        %ANSI   = 2
        %EBCDIC = 3
        Global IsRunning&
        Declare Function ASA_CVT2XFP Lib "FOX_ASA.DLL"(ByVal InFil$,ByVal UtFil$,ByVal BlkLen%,ByVal CharSet%,ByVal Hdr$,ByVal ProgBar&) As Long   
        Declare Function ASA_ABORT Lib "FOX_ASA.DLL"()As Long
        Declare Function ASA_RETCODE Lib "FOX_ASA.DLL"(EC As ErrResult)As Long
        
        CallBack Function RunButton()
        If isRunning& <> 0 Then Exit Function
        Local ThId&
         Thread Create Test(CBHndl) To ThId&
         Thread Close ThId& To ThId&  
        End Function
        
        CallBack Function CancelButton()
          Call ASA_ABORT()
        End Function
        
        CallBack Function QuitButton()
          Dialog End CbHndl, 0
        End Function
        
        '------------------------------------------------------------------------------
        
        Function PbMain () As Long
          $Register None
        '--create the testfile 130 MB in size------------
           If Dir$("C:\ASATEST.001")="" Then
            local x%,i&,Rad$
            For i& = Asc("A") to Asc("Z")
             Rad$ = Rad$ & "0" & String$(49,i&) & $CRLF
            Next i&
            x%=Freefile
            Open "C:\ASATEST.001" for binary as x%
            For i& = 1 to 100000 
             Put$ x%,Rad$
            Next i&    
            Close x%
           End If
        '------------------------------------------------
          Local hDlg   As Long
          Local result As Long
          Dialog New 0, "FOX ASA-TEST", ,, 200, 50, 0, 0 To hDlg
          Control Add "msctls_progress32",hDlg,100,"",5,5,185,12,%WS_CHILD Or %WS_VISIBLE,%WS_EX_CLIENTEDGE
          Control Add TextBox,hDlg,200,"",5,18,185,12
          Control Add Button, hDlg, 101, "Run AsaTest", 5, 35, 50, 14 Call RunButton
          Control Add Button, hDlg, 102, "Cancel Test", 65, 35, 50, 14, 0 Call CancelButton
          Control Add Button, hDlg, 103, "Quit", 125, 35, 50, 14, 0 Call QuitButton
          Dialog Show Modal hDlg 
        
        End Function
        
        Function Test(ByVal hDlg&)As Long
        Local Tmp$,InFil$,UtFil$,BlkLen%,CharSet%,Hdr$,Rc&
        Local EC As ErrResult
          isRunning& = 1
          InFil$ = "C:\ASATEST.001"
          UtFil$ = "C:\ASATEST.PCC"
          BlkLen% = 0 'Indicate CRLF-terminated
          CharSet% = %ASCII
          Hdr$ = "TESTING|FICHTEST|3|4|5|6|7|8|TESTAPP|0123456|"
          Control Set Text hDlg&,200,"Test Started"
          rc& = ASA_CVT2XFP(InFil$,UtFil$,BlkLen%,CharSet%,Hdr$,GetDlgItem(hDlg&,100))   
          If rc& = 0 Then
           Control Set Text hDlg&,200,"Alles Ok"
          Else
           Call ASA_RETCODE(EC)
           Tmp$ = Ec.FelRad
           Replace Chr$(0) With Chr$(1) In Tmp$
           Control Set Text hDlg&,200,"Error= " & Format$(rc&) & "| " & Tmp$
          End if 
          isRunning& = 0
        End Function
        ------------------
        Fred
        mailto:[email protected][email protected]</A>
        http://www.oxenby.se


        [This message has been edited by Fred Oxenby (edited April 13, 2000).]
        Fred
        mailto:[email protected][email protected]</A>
        http://www.oxenby.se

        Comment


        • #44
          James,

          The functions I had in mind are the standard ones that PowerBASIC
          use for dynamic string which are all BYTE size in allocation &
          deallocation.

          000041F4 0 SysAllocStringByteLen
          000041F8 0 SysFreeString
          000041FC 0 SysStringByteLen

          There is something obvious about the problem that Fred is having
          and that is that his code works correctly in 9x and win2k and on
          some installations of NT4.

          By reduction, this indicates that there is something wrong with
          either the installation of NT4 or the service pack 6 that it is
          using.

          Now Bob Zale's asm code for the function is sound, it works too
          well everywhere else to be problematic so this leaves the OLE
          string functions used to allocate, resize and deallocate the OLE
          string used.

          These normally work well on everything else so the next step is the
          OLE string pool and it is here that no-one knows what has been
          changed in the service pack 6.

          What I suggested before was to reduce any compounded memory usage
          by flushing each disk write to disk and testing if de-allocating
          at the end of each iteration of the loop slowed down or stopped
          the problem.

          Fred's report of the function stopping after a partial operation
          has the smell of memory problems so the idea was to try and work
          around the mess up which appears to be another one from Microsoft
          with the service pack 6.

          I keep getting bad reports from people who have upgraded to NT4
          Service pack 6 so I am inclined to think that the problem rests
          with it, not Fred's code.

          Regards

          [email protected]

          ------------------
          hutch at movsd dot com
          The MASM Forum - SLL Modules and PB Libraries

          http://www.masm32.com/board/index.php?board=69.0

          Comment


          • #45
            Steve,
            duh... I was looking at SysAllocString not SysAllocStringByteLen

            James


            ------------------

            Comment

            Working...
            X