Jump to content
dkprojektai

About error handling in parallel.for

Recommended Posts

Hi, made tests and finally find out how works error handling in Omnithread parallel.for. Here is my testing:

 

procedure TbtnParallelFor.btnParallelForExceptionClick(Sender: TObject);
var
  i: Integer;
  Loking_elem: TOmniMREW;
  Error_stack_text: string;
begin

  Error_stack_text:= '';

      Parallel.For(0, 10,1).Execute(
      procedure (i: integer)
      begin
        Try
          
		//What will happen if here will be error from dll???


          if i = 4 then 
          try

          finally
            integer(nil^):= 0;
          end;

          if i = 5 then
          integer(nil^):= 0;
          raise Exception.Create('Exception in thread ' +
            TThread.Current.ThreadID.ToString);
        except

          on E: Exception do begin
            Try
              if i = 5 then
              integer(nil^):= 0;
              Loking_elem.EnterWriteLock;
              Error_stack_text:= Error_stack_text + #13#10 + '---' + E.StackTrace;
              Loking_elem.ExitWriteLock;
            except
              on E: Exception do begin
                Loking_elem.EnterWriteLock;
                Error_stack_text:= Error_stack_text + #13#10 + '---' + E.StackTrace;
                Loking_elem.ExitWriteLock;
              end;
            end;
          end;
        end;
      end);


  Memo1.Lines.Text:= Error_stack_text;
end;

 

In my application (not in this example) I still getting application terminate on error and I can't cache it. I work with many dll's in commented section. I want to ask, what will happen if in there will be an error from dll? Is there any solution to cache it?

 

Fault Offset:

Faulting application name: Application.exe, version: 4.6.0.0, time stamp: 0x5d7fec1f
Faulting module name: KERNELBASE.dll, version: 6.2.9200.16384, time stamp: 0x5010ac2f
Exception code: 0xe06d7363
Fault offset: 0x00014b32
Faulting process id: 0x31c0
Faulting application start time: 0x01d56d40dd25c4a4
Faulting application path: C:\Application.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll
Report Id: 3ff93c8d-d950-11e9-93fa-0a94ef1b475e
Faulting package full name: 
Faulting package-relative application ID: 

Leads me to:

Found:
  Provider: TELDebugInfoMap
  Location: (00C63D20){ANPR_VID.exe     } [06483D20] OtlParallel.TOmniParallelSimpleLoop.Execute[2]$ActRec.$0$Body (Line 3440, "OtlParallel.pas" + 16) + $0
    Unit: OtlParallel
    Source: OtlParallel.pas
    Class: TOmniParallelSimpleLoop.Execute[2]$ActRec
    Routine: $0$Body
    Line: 3440

    Routine offset (bytes): 96
    Routine offset (lines): 16
    Line offset (bytes): 0

That is why I think that error rises dll and parallel.for is not able to handle it. Any comments are welcome.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×