Scheduling in build_phase()

I am having the following code inside env::build_phase()

myagent = master_agent::type_id::create(“myagent”, this);
uvm_config_db#(master_agent_sequencer)::set(this, “virt_seqr”, “master_sequencer”, myagent.sequencer);

I am retrieving the myagent.sequencer handle in virtual sequencer::connect_phase(). However, I am getting null pointer in virtual sequencer. When I ran with +UVM_CONFIG_DB_TRACE and +UVM_PHASE_TRACE, the statement CFGDB/SET gets printed before master_sequencer::buid_phase() completed.

Does this mean both the statements in the env are scheduled together?
I have similar statements with master_agent_config class and they execute in the correct order.

Please let me know if I am missing anything here.

In reply to anacharya:

myagent.sequencer is most likely null when you execute the uvm_config_db#()::set(). It is set by value, not by reference.

You would need to explain a little more about what you’re trying to do, but a general suggestion is creating a single configuration object for each agent and sharing that handle. That configuration object can then be used to share the values.