Null pointer dereference bucause of print in connect_phase

class yapp_tx_agent extends uvm_agent;

  //  This field determines whether an agent is active or passive.
  protected uvm_active_passive_enum is_active = UVM_PASSIVE;
  
  yapp_tx_monitor   monitor;
  yapp_tx_sequencer sequencer;
  yapp_tx_driver    driver;
  
  // component macro
  `uvm_component_utils_begin(yapp_tx_agent)
    `uvm_field_enum(uvm_active_passive_enum, is_active, UVM_ALL_ON)
  `uvm_component_utils_end

  // Constructor - required syntax for UVM automation and utilities
  function new (string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new

  // UVM build_phase() method
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    monitor = yapp_tx_monitor::type_id::create("monitor", this);
    if(is_active == UVM_ACTIVE) begin
      sequencer = yapp_tx_sequencer::type_id::create("sequencer", this);
      driver = yapp_tx_driver::type_id::create("driver", this);
    end
  endfunction : build_phase

  // UVM connect_phase() method
  function void connect_phase(uvm_phase phase);
    if(is_active == UVM_ACTIVE) 
      // Connect the driver and the sequencer 
      driver.seq_item_port.connect(sequencer.seq_item_export);

      //driver.print();
  endfunction : connect_phase

  function void start_of_simulation_phase(uvm_phase phase);
    `uvm_info(get_type_name(), {"start of simulation for ", get_full_name()}, UVM_HIGH);
  endfunction : start_of_simulation_phase

endclass : yapp_tx_agent

if I uncomment the driver.print() line from connect_phase…I get following error…

ncsim: *E,TRNULLID: NULL pointer dereference.
File: /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_object.svh, line = 901, pos = 30
Scope: worklib.uvm_pkg::uvm_object::sprint
Time: 0 FS + 13
Verilog Stack Trace:
0: function worklib.uvm_pkg::uvm_object::sprint at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_object.svh:901
1: function worklib.uvm_pkg::uvm_object::print at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_object.svh:880
2: function worklib.yapp_pkg::yapp_tx_agent@4931_3.connect_phase at …/sv/yapp_tx_agent.sv:52
3: function worklib.uvm_pkg::uvm_connect_phase@1966_3.exec_func at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_common_phases.svh:101
4: function worklib.uvm_pkg::uvm_bottomup_phase@1966_3.execute at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_bottomup_phase.svh:104
5: function worklib.uvm_pkg::uvm_bottomup_phase@1966_3.traverse at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_bottomup_phase.svh:81
6: function worklib.uvm_pkg::uvm_bottomup_phase@1966_3.traverse at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_bottomup_phase.svh:61
7: function worklib.uvm_pkg::uvm_bottomup_phase@1966_3.traverse at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_bottomup_phase.svh:61
8: function worklib.uvm_pkg::uvm_bottomup_phase@1966_3.traverse at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_bottomup_phase.svh:61
9: task worklib.uvm_pkg::uvm_phase@2082_4.execute_phase at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_phase.svh:1208
10: process in worklib.uvm_pkg::uvm_phase::m_iterate_through_phases at /vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_phase.svh:1983

/vl/edatools/extern/Cadence/INCISIV/11.1/001-p/tools/uvm/uvm_lib/uvm_sv/sv/base/uvm_object.svh:901 printer.print_object(get_name(), this);

otherwise while commented everything works fine…can anybody please tell me the reason…

Hi pravin_tavagad,
Can you tell me that, print is a task or function in driver? If print is a function in driver, then problem will not be occur. If print is a task in driver, then problem will occur. You cannot call task in function. Please check your print code in your driver.

Thanks & regards,
Sudheer.

In reply to sudheer:

Hi sudheer,

here print is the default method provided by uvm_driver…I dont have any function/task print () in my driver…

Hi,

I guess your agent is not configured as UVM_ACTIVE and the driver is not created.
Thus you get the NULL pointer error when you try to access the print() method of the driver.
Change your code to

function void connect_phase(uvm_phase phase);
   if(is_active == UVM_ACTIVE) begin
      // Connect the driver and the sequencer 
      driver.seq_item_port.connect(sequencer.seq_item_export);
      driver.print();
   end
endfunction : connect_phase

In reply to msummer:

hi msummer,

Now its working fine…

thanks and regs,

Pravin