[fpc-pascal] Thread problem

Paul Renaud prenaud167 at yahoo.com
Sun Sep 6 19:00:00 CEST 2020


IHello,

I'm having a problem with the OS/2 version of the compiler.

This simplified version of my program keeps generating an exception
when compiled and run in EComStation 1.2, OS/2 versions 4.5 and 4 
but runs fine when compiled for Windows. 

Program Test1( Input, Output );

{$S+}

  Const
    StackSize = 1000000;
    
    Max_Array = 5000;

  Type
    Data_Array = packed array[ 0 .. Max_Array ] of LongInt;

  Function MyThread( P: Pointer ): PtrInt;
    Var
      Data: Data_Array;
      Indexer: LongInt;
    Begin
      MyThread := 0;
      For Indexer := 1 to Max_Array do
        Data[ Indexer ] := 0;
    End;  
    
  Var
    Handle: LongWord;
    My_Result: LongInt;
  Begin
    WriteLn( 'Test1 starting' );
    My_Result := BeginThread( @MyThread, Nil, Handle, StackSize );

    My_Result := WaitForThreadTerminate( Handle, 0 );
    WriteLn( 'Test1 finished' );
  End.

The error generated is...

SYS1808:
The process has stopped.  The sofware diagnostic 
code (exception code) is  0005.

the command I used to compile it is:

fpc Test1.pas -Se -gl

This exception appears to be generated before my thread gets control,
so I can't install my own exception handlers to intercept it.

Any help would be appreciated.
Thanks,
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200906/e8849f2f/attachment.htm>


More information about the fpc-pascal mailing list