Skip to content

[Bug] VerifyStream::Verify causes dereferencing an invalid pointer #17798

Open
@l0r3m1psum

Description

@l0r3m1psum

As the title says. In particular the following statement in very_well_formed.cc

Verify(it == currently_defined_.end() || redefine_is_allowed)
          << "ValueError: "
          << "TIR is ill-formed, "
          << "due to multiple nested definitions of variable " << var
          << ".  It was first defined at " << it->second << ", and was re-defined at " << path;

allows for the espression it->second to be evaluated even when it == currently_defined_.end().

This happens to me with MSVC 19.43.34808.

Expected behavior

it should not be dereferenced.

Actual behavior

it is dereferenced.

Environment

I am running:

  • Windows 11 build 26100.3476
  • Python 3.11.0
  • LLVM 15.0.0
  • TVM commit 2c80e5c7a4d8d8c4125226beb16d792b964f3e5f

Steps to reproduce

Run the folowing script

import tvm
from tvm import relax
from tvm.relax.frontend import nn
from tvm import dlight as dl

class MLPModel(nn.Module):
	def __init__(self):
		super().__init__()
		self.fc1 = nn.Linear(784, 256)
		self.relu1 = nn.ReLU()
		self.fc2 = nn.Linear(256, 10)
	def forward(self, x):
		x = self.fc1(x)
		x = self.relu1(x)
		x = self.fc2(x)
		return x

mod, param_spec = MLPModel().export_tvm(
	spec={'forward': {'x': nn.spec.Tensor((1, 784), 'float32')}}
)

zero_pipeline = relax.get_pipeline('zero')
mod_op = zero_pipeline(mod)

with tvm.target.Target('cuda'):
	gpu_mod = dl.ApplyDefaultSchedule(
		dl.gpu.Matmul(),
		dl.gpu.Fallback(),
	)(mod_op)

exec = tvm.compile(gpu_mod, target='cuda')
dev = tvm.device('cuda', 0)
vm = relax.VirtualMachine(exec, dev)

Triage

  • needs-triage
  • tir:analysis

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions