Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006581 [JEDI Code Library] JclCompression crash always 2017-07-19 10:09 2019-06-15 16:29
Reporter baka0815 View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version Version 2.5 (Subversion repository/Daily zips)
Summary 0006581: Compress ZIP files with OnProgress event
Description We're trying to compress multiple files into a ZIP file using JclCompression.

When we attach an OnProgress event the process freezes.

In the attached example we're tying to add a line to a TMemo in the OnProgress event. This does not work and the message "OnCompress() Beginn" is never displayed in the TMemo.

Here is the code of the GetCount() method which is called in the Lines.Add() method:

---8<--- Vcl.StdCtrls ---
function TMemoStrings.GetCount: Integer;
begin
  Result := 0;
{$IF DEFINED(CLR)}
  if Memo.HandleAllocated or (Memo.WindowText <> '') then
{$ELSE}
  if Memo.HandleAllocated or (Memo.WindowText <> nil) then
{$ENDIF}
  begin
    Result := SendMessage(Memo.Handle, EM_GETLINECOUNT, 0, 0); // <-- hangs on this line
    if SendMessage(Memo.Handle, EM_LINELENGTH, SendMessage(Memo.Handle,
      EM_LINEINDEX, Result - 1, 0), 0) = 0 then Dec(Result);
  end;
end;
--- Vcl.StdCtrls--->8---

The process hangs when it tries to send a message to the Memo.Handle.

When we remove the Memo.Lines.Add() the process hangs on the following line while trying to set the new progress:

---8<--- Vcl.ComCtrls ---
procedure TProgressBar.SetPosition(Value: Integer);
begin
  if not F32BitMode and ((Value < 0) or (Value > Limit16)) then
    ProgressLimitError;
  if HandleAllocated then
    SendMessage(Handle, PBM_SETPOS, Value, 0) // <-- hangs on this line
  else
    FPosition := Value;
end;
--- Vcl.ComCtrls --->8---

There are some different things to create the ZIP file correctly
* removing the OnProgress event
* add only one file
* setting the compression method to cmCopy
* compressing as a 7z file

However we need to compress multiple files, compress them and it has to be a ZIP file.
Additional Information Delphi: 10.1 Berlin Update 2
JCL: current git (e167f07a1c57cf7304bf38f982fce19bcc62a3a1 on Apr 9, 2017)
7z.dll: 4.62, 4.65, 9.20, 9.38, 16.04 and 17.00
Tags No tags attached.
Fixed in revision
IDE version Delphi/C++Builder XE3
Attached Files zip file icon example.zip [^] (53,924 bytes) 2017-07-19 10:09

- Relationships

-  Notes
(0021434)
baka0815 (reporter)
2017-09-01 17:01

One and a half month no change - is anyone still reading this?
(0021435)
baka0815 (reporter)
2017-09-13 10:10

Ok, it looks like it's some locking problem.

What we're now doing is to compress in a thread (or a task):

---8<--- Code ---
      Task := TTask.Create(
        procedure
        begin
          Archive.Compress;
        end);
      Task := Task.Start;

      while (Task.Status in [TTaskStatus.WaitingToRun, TTaskStatus.Running]) do
      begin
        Application.ProcessMessages;
      end;
--->8--- Code ---

This works for us.
However this locking is not the case while decompression a ZIP file or compressing a 7z file.

Is this a bug inside the 7z.dll?
(0021690)
mh (reporter)
2019-04-14 12:08

Is it necessary to use SendMessage instead of PostMessage? I'm asking because SendMessage blocks the caller until the message has been processed and if the receiver for the message doesn't have working message processing at that particular point in time it could block the caller endlessly.
(0021821)
baka0815 (reporter)
2019-05-10 18:20

Well, as you can see the SendMessage() is in the Delphi Vcl-Code not in our code, so there is nothing we can do about.
However it's weird that it's working with the settings I mentioned (compressing only 1 file, not compressing, ...).
(0021863)
mh (reporter)
2019-06-15 16:29

What happens if the code in the OnProgress Method is put into something like synchronize? Mabye it needs to run in the context of the main thread?

- Issue History
Date Modified Username Field Change
2017-07-19 10:09 baka0815 New Issue
2017-07-19 10:09 baka0815 File Added: example.zip
2017-07-19 10:09 baka0815 IDE version => Delphi/C++Builder XE3
2017-09-01 17:01 baka0815 Note Added: 0021434
2017-09-13 10:10 baka0815 Note Added: 0021435
2019-04-14 12:08 mh Note Added: 0021690
2019-05-10 18:20 baka0815 Note Added: 0021821
2019-06-15 16:29 mh Note Added: 0021863


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker