cdew / omnithreadlibrary

Automatically exported from code.google.com/p/omnithreadlibrary
0 stars 0 forks source link

Parallel.ForEach().NumTasks().Execute causes crash when using dynamically loaded packages #57

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create runtime bpl with a unit uTest with a procedure TestParallel
2. The routine TestParallel should contain something like
  Parallel.ForEach(1,4).NumTasks(4).Execute(
    procedure (const v:integer)
    begin
      //actually does nothing
    end
  );
3. Create an minimal app, with a button
4. The event handler dynamically loads the package using LoadPackage
   Executes the TestParallel procedure
   Unloads the package
5. After pressing the button everything still appears to be OK
6. Now close the main app. --> crash

The crash is probably caused by some interface being released that points to 
some destructor code that is in the unloaded package. My first guess would be 
that the local IOmniParallelloop<integer> interface only exists in the package 
and causes the problem.
Obviously some cleaning up is missed. When the Execute call is omitted, the 
problem does NOT occur.

What is the expected output? -> No crash during shutdown
What do you see instead? -> a crash during shutdown

What version of the product are you using? 1.34, 2013-01-08
On what operating system? Win7x64 running under VMWare, 

Please provide any additional information below.

Original issue reported on code.google.com by h.hasen...@gmail.com on 22 Jan 2014 at 9:19

GoogleCodeExporter commented 9 years ago
Please provide a test case (full, compilable project).

Original comment by gabr42 on 22 Jan 2014 at 9:28

GoogleCodeExporter commented 9 years ago
When using a construction like    
lAtomicIndex=-1;
Parallel.ParallelTask.NumTasks(lThreadCount).Execute(
  procedure ()
          VAR lMyIndex:integer;
          begin
            lMyIndex:=AtomicIncrement(lAtomicIndex);
            // do something 
          end
  );

then the problem is gone. So obviously, the TParallelloop<integer> created by 
the compiler code resides only in the dynamic package. Still it appears strange 
to me that the object is not destroyed within the calling routine of 
parallel.foreach().NumTasks.Execute(...

Original comment by h.hasen...@gmail.com on 22 Jan 2014 at 10:25

GoogleCodeExporter commented 9 years ago
Sent by mail.

Original comment by h.hasen...@gmail.com on 24 Jan 2014 at 2:55

GoogleCodeExporter commented 9 years ago
The mail to omnithreadlibrary@googlecode.com bounced, so I have attached it 
here.

Original comment by h.hasen...@gmail.com on 27 Jan 2014 at 7:40

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by gabr42 on 27 Jan 2014 at 9:47