cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
326 stars 92 forks source link

[Pass] Fix Ill-Formed C++ Code in reuse_at #226

Closed seanlatias closed 4 years ago

seanlatias commented 4 years ago

According to the C++ document, it is ill-formed to bind a temporary (an unnamed variable) to a reference member in a constructor initializer list. [link1] [link2]

Following is an example provided by the document.

struct A {
  A() : v(42) { }   // error
  const int& v;
};
seanlatias commented 4 years ago

Should solve #221 and #222.

seanlatias commented 4 years ago

In our case, it's slightly more complicated, but the root cause is the same.

class A {
  A(const int& x) : x_(x) {}
  const int& x_;
};

// before fix
A a(5);

// after fix
int x = 5;
A a(x);
zhangzhiru commented 4 years ago

Do we have a test case that can reproduce the segfault on our server? If so, please add it to the regression.

seanlatias commented 4 years ago

Unfortunately, no. It can only be observed on other platforms.

hecmay commented 4 years ago

@seanlatias We can reproduce the error on our VM servers using docker. Please try this docker image: #227

chhzh123 commented 4 years ago

Thanks. This PR is the same with my solution, and it fixes #222 .

chhzh123 commented 4 years ago

I also suggest adding a -g flag to the TVM Makefile in this PR, which would be helpful to locate the SegFault using gdb. https://github.com/cornell-zhang/heterocl/blob/c67dfede32b84f6f0d7402a6a05d9320afd4bd0f/tvm/Makefile#L29

seanlatias commented 4 years ago

I also suggest adding a -g flag to the TVM Makefile in this PR, which would be helpful to locate the SegFault using gdb. https://github.com/cornell-zhang/heterocl/blob/c67dfede32b84f6f0d7402a6a05d9320afd4bd0f/tvm/Makefile#L29

Let me add this to the developer guide.