Event marked with BAD-HANDLE / REFERENCE error - event is passed as reference argument to TASK and used in FORK-JOIN within TASK

Hello,
I do not know why this construction returns me a BAD-HANDLE or REFERENCE error in questa 2019.4 for a line within fork-join - that is waiting for an event @(dut_filter_tau_trg).

Below is just dummy code - but I want to use this approach within filter model prediction implementation. Why during the run-time questa
@(dut_filter_tau_trg); returns a BAD-REFERENCE?

Because if I write @(dut_filter_tau_trg); out of FORK-JOIN within that Task everything works fine - just that I cannot spawn threads within that Task and wait within spawned thread for event trigger passed to Task as handle.

Can you please tell me what am I missing here?


...
...
  //*************************************************************************
  // Task: filter
  // Calculates filtered values according to parameters
  //*************************************************************************
  task filter(ref    process      proc,
              ref    event        dut_filter_tau_trg,
              // ... additional arguments 
              );
    
    // Internal Filter event trigger
    event recalc_filter_trg;
    
    // -----------------------------------------------------------
    // Assign Process Variable
    // -----------------------------------------------------------
    proc = process::self();

    fork
      forever begin 
         @(dut_filter_tau_trg);
         
         // DO-SOMETHING_1

         // Fire-trigger
         -> recalc_filter_trg;
      end
      forever begin
         @(recalc_filter_trg);
 
         // DO-SOMETHING_2
      end
    join
    
  endtask : filter
...
...
  task run_phase(uvm_phase phase);
    forever begin
      @(reset_trg);
      // -----------------------------------------------------
      fork
        ....
        // BG Servo Pressure 2 Filter
        filter(bg_servo_press2_filter_prc,                               // proc_filter_output
               m_tb_internal_signals.dut_bg_servo_press2_filter_tau_trg, // dut_filter_tau_trg
               // ... additional arguments                               // ... additional arguments 
        ) 
        ....
      join_none // CONTINUE-IMMEDIATELY
      // -----------------------------------------------------
    end // END-FOREVER-LOOP
  endtask : run_phase

In reply to slackers:

There’s is not enough code here to recreate your problem, but the LRM does not allow you to refer to arguments passed by ref from within a fork/join block. But actually you don’t need the ref qualifier with handle-like variables such as events, classes and virtual interfaces. The variables contain references anyways. Use input instead (which is the implicit default).

I was looking for this reply: “but the LRM does not allow you to refer to arguments passed by ref from within a fork/join block.”

Thank you Dave!

I know about that ref for events - but still I used ref qualifier as a good practice to tell other people - that may not know about it or they are from different background - and that will read code after me - that this variable is used as reference within task although it is always a reference with or without ref qualifier used in for that event input argument. Not sure whether it is better or not.

The problem was exactly that spawned thread within fork-join of the given Task above wasnt able to see the referenced arguments of the Task - my solution was to create separate Tasks for each thread (that should have been spawned in that single Task of previous implementation) and synchronize those separate Tasks with some sync events and then call them wrapped in the fork-join_none within the run_phase().