Threadsafe - Compiler Check Bug - Prevent IMA at runti

Just starting out? Need help? Post your questions and find answers here.
majk
New User
New User
Posts: 6
Joined: Wed Jun 07, 2006 2:48 pm

Threadsafe - Compiler Check Bug - Prevent IMA at runti

Post by majk »

You should extend the compiler check for the situation, that a pb user has forgotten any parameter for a threaded procedure.

Without threadsafe the code does run without any problem.

With activated threadsafe the code crashes with IMA at "ProcedureReturn".

Code: Select all


Procedure P_Thread_QueuMaster()

  ; This Procedure crash with enabled threadsafe at "EndProcedure" with
  ; a hard to find IMA.
  
  Define tmp.l
  
  While tmp < 1000
    Delay(1)
    tmp+1
  Wend

EndProcedure

  Define THREAD_ID_QUEUMASTER.l

  THREAD_ID_QUEUMASTER = CreateThread(@P_Thread_QueuMaster(),0)

  While IsThread(THREAD_ID_QUEUMASTER)
      Debug "THREAD_ID_QUEUMASTER is running"
      Delay(50)
  Wend
If i add a parameter to procedure, as i should, i get no problem. The following code works without any problems.

Code: Select all

Procedure P_Thread_QueuMaster(bla.)

  ; This Procedure does not crash 
  
  Define tmp.l
  
  While tmp < 1000
    Delay(1)
    tmp+1
  Wend

EndProcedure

  Define THREAD_ID_QUEUMASTER.l

  THREAD_ID_QUEUMASTER = CreateThread(@P_Thread_QueuMaster(),0)

  While IsThread(THREAD_ID_QUEUMASTER)
      Debug "THREAD_ID_QUEUMASTER is running"
      Delay(50)
  Wend
Can you please add a check at compilation time?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It's impossible for the compiler check because the parameter is simply a memory address. Passing a variable is legal.

How would the compiler know that this is correct?

Code: Select all

Procedure Thread1(Void)

EndProcedure

Procedure Thread2(Void)

EndProcedure

If ProgramFilename() = "blah"
  Proc = @Thread1()
Else
  Proc = @Thread2()
EndIf

CreateThread(Proc, Param)
Post Reply