From fb5f7ff5330e3999970e50a5b89fdb446218c5ac Mon Sep 17 00:00:00 2001 From: Luke Hutton Date: Wed, 27 May 2020 14:45:21 +0100 Subject: [PATCH] [RELAY] Fix segfault in pretty print when ObjectRef is null Encountered when pretty printing module with function attribute equal to NullValue(). Change-Id: I2e7b304859f03038730ba9c3b9db41ebd3e1fbb5 --- src/printer/relay_text_printer.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/printer/relay_text_printer.cc b/src/printer/relay_text_printer.cc index 076339d774b4..ad16f862ac2b 100644 --- a/src/printer/relay_text_printer.cc +++ b/src/printer/relay_text_printer.cc @@ -91,7 +91,8 @@ Doc RelayTextPrinter::PrintScope(const ObjectRef& node) { } Doc RelayTextPrinter::PrintFinal(const ObjectRef& node) { - if (node->IsInstance() && !node->IsInstance()) { + if (node.defined() && node->IsInstance() && + !node->IsInstance()) { // Temporarily skip non-relay functions. // TODO(tvm-team) enhance the code to work for all functions } else if (node.as()) { @@ -105,8 +106,8 @@ Doc RelayTextPrinter::PrintFinal(const ObjectRef& node) { } Doc RelayTextPrinter::Print(const ObjectRef& node, bool meta, bool try_inline) { - bool is_non_relay_func = - node->IsInstance() && !node->IsInstance(); + bool is_non_relay_func = node.defined() && node->IsInstance() && + !node->IsInstance(); if (node.as() && !is_non_relay_func) { return PrintExpr(Downcast(node), meta, try_inline); } else if (node.as()) {