Issues raising objections inside a forked thread in phase_ready_to_end funciton

When I do this, the simulator gets some exception and bombs and prints some stack trace.

function void phase_ready_to_end(uvm_phase phase);
   fork
      begin
         wait(vif.rst);  
         phase.raise_objection(this, "Scoreboard objection");

After moving the raising of objection outside the thread (like below), it works. Is there something wrong with the above code, or could it be a simulator bug?

function void phase_ready_to_end(uvm_phase phase);
   phase.raise_objection(this, "Scoreboard objection");
   fork
      begin
         wait(vif.rst);

It would help if you showed the actual message to to know if there is a simulator bug.

But in any case, you need to raise the objection to the phase immediately, before it ends.
And usually you need to only do this for a specific phase

function void phase_ready_to_end(uvm_phase phase);
 if(phase.get_name == "run")begin
 phase.raise_objection(this, "Scoreboard objection");
   fork
      begin
         wait(vif.rst);
         phase.drop_objection(this, "Scoreboard objection");
       end
    join_none

In reply to dave_59:

Dave,

I guess that error had something to do with the phases. It’s fixed when I do what you suggested.
On a different note, I see some weird issue when I use RTL signals via VIF in this phase_ready_to_end function -
I don’t see any issues when I remove the wait(vif.rst) line from the code in your reply. But, when I keep that line (or waiting on any VIF signal), I see that that signal is driven to X in the waves. Waiting on some internal scoreboard variables seems to work fine. It is just with the interface signals. I use bind statements to bind the interface into the RTL/TB. I do the same thing everywhere, and I haven’t seen any issues like this. The weird part is that I have this signal as an input in my interface, and when I sample it in the phase_ready_to_end task, it goes to X, else, it’s stable value as it’s being driven elsewhere. Can you help?

interface rtl_if (
   input  logic     rst
);
endinterface
bind rtl_top rtl_if rtl_if(.rst(rst));