It is currently Wed Jan 27, 2021 11:47 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [Done] ClosePack()
PostPosted: Fri Apr 17, 2020 1:37 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5222
Location: Germany
Hi,

here
viewtopic.php?p=552745#p552745

was something not working.
I jumped in.

For me it looks like a bug.

Test code:
Code:
#ShowBug = #True

UseZipPacker()

File = OpenPack(#PB_Any, "c:\tmp\test.zip")
If File
  If ExaminePack(File)
  CompilerIf Defined(ShowBug, #PB_Constant)
    While NextPackEntry(File)
    Wend
  CompilerEndIf
  EndIf
  ClosePack(File)
EndIf

; this is only to see an action between in procmon
File = CreateFile(#PB_Any, "c:\tmp\test.123")
If File
  CloseFile(File)
  DeleteFile("c:\tmp\test.123")
EndIf

File = OpenFile(#PB_Any, "c:\tmp\test.zip", #PB_File_Append)
If File
  MessageRequester("OK", "Ok")
  CloseFile(File)
Else
  MessageRequester("Error", "Error")
EndIf


I used SysInternals ProcMon to see the file accesses.

Without #ShowBug

6828 CreateFile C:\tmp\test.zip SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened
6828 QueryInformationVolume C:\tmp\test.zip BUFFER OVERFLOW VolumeCreationTime: 28.09.2018 17:06:27, VolumeSerialNumber: 4ED4-AC1E, SupportsObjects: True, VolumeLabel: Winֹ
6828 QueryAllInformationFile C:\tmp\test.zip BUFFER OVERFLOW CreationTime: 17.04.2020 13:24:26, LastAccessTime: 17.04.2020 13:24:28, LastWriteTime: 17.04.2020 13:24:28, ChangeTime: 17.04.2020 14:01:04, FileAttributes: A, AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False, IndexNumber: 0x7e00000002a9ba, EaSize: 0, Access: Generic Read, Position: 0, Mode: Synchronous IO Non-Alert, AlignmentRequirement: Word
6828 ReadFile C:\tmp\test.zip SUCCESS Offset: 0, Length: 65.536, Priority: Normal
6828 QueryStandardInformationFile C:\tmp\test.zip SUCCESS AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False
6828 QueryStandardInformationFile C:\tmp\test.zip SUCCESS AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False
6828 ReadFile C:\tmp\test.zip SUCCESS Offset: 1.007.616, Length: 16.384
6828 QueryStandardInformationFile C:\tmp\test.zip SUCCESS AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False
6828 CloseFile C:\tmp\test.zip SUCCESS
6828 CreateFile C:\tmp\test.123 SUCCESS Desired Access: Generic Read/Write, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: 0, OpenResult: Created
6828 CloseFile C:\tmp\test.123 SUCCESS
6828 CreateFile C:\tmp\test.123 SUCCESS Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
6828 QueryAttributeTagFile C:\tmp\test.123 SUCCESS Attributes: A, ReparseTag: 0x0
6828 SetDispositionInformationEx C:\tmp\test.123 SUCCESS Flags: FILE_DISPOSITION_DELETE, FILE_DISPOSITION_POSIX_SEMANTICS, FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK
6828 CloseFile C:\tmp\test.123 SUCCESS
6828 CreateFile C:\tmp\test.zip SUCCESS Desired Access: Generic Read/Write, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: 0, OpenResult: Opened
6828 QueryStandardInformationFile C:\tmp\test.zip SUCCESS AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False
6828 CloseFile C:\tmp\test.zip SUCCESS


With #ShowBug

11452 CreateFile C:\tmp\test.zip SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened
11452 QueryInformationVolume C:\tmp\test.zip BUFFER OVERFLOW VolumeCreationTime: 28.09.2018 17:06:27, VolumeSerialNumber: 4ED4-AC1E, SupportsObjects: True, VolumeLabel: Winܘ
11452 QueryAllInformationFile C:\tmp\test.zip BUFFER OVERFLOW CreationTime: 17.04.2020 13:24:26, LastAccessTime: 17.04.2020 13:24:28, LastWriteTime: 17.04.2020 13:24:28, ChangeTime: 17.04.2020 14:01:04, FileAttributes: A, AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False, IndexNumber: 0x7e00000002a9ba, EaSize: 0, Access: Generic Read, Position: 0, Mode: Synchronous IO Non-Alert, AlignmentRequirement: Word
11452 ReadFile C:\tmp\test.zip SUCCESS Offset: 0, Length: 65.536, Priority: Normal
11452 QueryStandardInformationFile C:\tmp\test.zip SUCCESS AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False
11452 QueryStandardInformationFile C:\tmp\test.zip SUCCESS AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False
11452 ReadFile C:\tmp\test.zip SUCCESS Offset: 1.007.616, Length: 16.384
11452 QueryStandardInformationFile C:\tmp\test.zip SUCCESS AllocationSize: 1.024.000, EndOfFile: 1.024.000, NumberOfLinks: 1, DeletePending: False, Directory: False
11452 ReadFile C:\tmp\test.zip SUCCESS Offset: 0, Length: 65.536
11452 ReadFile C:\tmp\test.zip END OF FILE Offset: 32.747.815, Length: 65.536
11452 CreateFile C:\tmp\test.123 SUCCESS Desired Access: Generic Read/Write, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: 0, OpenResult: Created
11452 CloseFile C:\tmp\test.123 SUCCESS
11452 CreateFile C:\tmp\test.123 SUCCESS Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11452 QueryAttributeTagFile C:\tmp\test.123 SUCCESS Attributes: A, ReparseTag: 0x0
11452 SetDispositionInformationEx C:\tmp\test.123 SUCCESS Flags: FILE_DISPOSITION_DELETE, FILE_DISPOSITION_POSIX_SEMANTICS, FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK
11452 CloseFile C:\tmp\test.123 SUCCESS
11452 CreateFile C:\tmp\test.zip SHARING VIOLATION Desired Access: Generic Read/Write, Disposition: OpenIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: None, AllocationSize: 0
11452 CloseFile C:\tmp\test.zip SUCCESS


As you can see when the NextPackEntry() loop is in use,
the file test.zip is not closed before an access to test.123

In my opinion it is a bug.

Tested with PB 5.72 x86 on Win10 x64.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug or no bug: ClosePack()
PostPosted: Fri Apr 17, 2020 2:26 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5222
Location: Germany
To get exactly the same zip file:
Code:
#BlockSize = 1024000

InitNetwork()

NewMap HeaderMap$()

File = CreateFile(#PB_Any, "c:\tmp\test.zip")
If File
 
  Repeat
    ResetMap(HeaderMap$())
    Debug "bytes=" + Str(StartAddr) + "-" + Str(StartAddr + #BlockSize - 1)
    HeaderMap$("Range") = "bytes=" + Str(StartAddr) + "-" + Str(StartAddr + #BlockSize - 1)
    HTTPRequest = HTTPRequest(#PB_HTTP_Get, "http://download.2gis.com/arhives/2GISData_Minvody-84.0.0.zip", "", 0, HeaderMap$())
    If HTTPRequest
      *Buffer = HTTPMemory(HTTPRequest)
      If *Buffer
        WriteData(File, *Buffer, MemorySize(*Buffer))
;        If MemorySize(*Buffer) < #BlockSize
          Exit = #True
;        EndIf
        FreeMemory(*Buffer)
      EndIf
      FinishHTTP(HTTPRequest)
    EndIf
    StartAddr + #BlockSize
  Until Exit
 
  CloseFile(File)
EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug or no bug: ClosePack()
PostPosted: Sat Apr 18, 2020 9:54 am 
Offline
Addict
Addict

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 970
<off topic>
Quote:
I used SysInternals ProcMon to see the file accesses.
...
6828 CreateFile C:\tmp\test.zip SUCCESS Desired Acce...
It's an interesting debug technique. How do you go about getting this kind of log? I tried with ProcMon (3.53) and couldn't track accesses to a file. Do I have to follow the program (PureBasic_Compilation0.exe ) or the data file (test.zip) ?

I set filter "ProcessName" "is" "PureBasic_Compilation0.exe"

Thanks
</off topic>
:wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug or no bug: ClosePack()
PostPosted: Sat Apr 18, 2020 11:07 am 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5222
Location: Germany
I use what I get to track down a problem :wink:

Quote:
I set filter "ProcessName" "is" "PureBasic_Compilation0.exe"


That's right.
Ok, in my case I uses the real exe name, since I compiled it before to an exe.

You have to enable/disable the different outputs.
In this case I enabled only the 'Show File System Activity'
But I thought that all outputs are enabled by default.

And I deleted all the events which not belonged to the problem after I copied the output into an editor.
(access to windows dlls ...)


Last edited by infratec on Sat Apr 18, 2020 11:15 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Bug or no bug: ClosePack()
PostPosted: Sat Apr 18, 2020 11:10 am 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5222
Location: Germany
Back to the problem:

Yes, the ZIP file is 'corrupted', since it is not complete.
But ClosePack() should close it, doesn't matter what happens in between.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bug or no bug: ClosePack()
PostPosted: Sun Apr 19, 2020 7:50 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14181
Location: France
It was a bug, thanks for the investigation ! Fixed.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Done] ClosePack()
PostPosted: Sun Apr 19, 2020 8:10 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5222
Location: Germany
Thank's for fixing :!:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye