Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling Blob->Reshape with zero causes a floating point exception #3583

Closed
elezar opened this issue Jan 21, 2016 · 3 comments
Closed

Calling Blob->Reshape with zero causes a floating point exception #3583

elezar opened this issue Jan 21, 2016 · 3 comments

Comments

@elezar
Copy link
Contributor

elezar commented Jan 21, 2016

Adding the following test to test_blob.cpp:

TYPED_TEST(BlobSimpleTest, TestReshapeZeroShape) {
  vector<int> shape(4);
  shape[0] = 0; shape[1] = 0; shape[2] = 0; shape[3] = 0;
  this->blob_->Reshape(shape);
  EXPECT_EQ(this->blob_->shape(), shape);
}

Results in the following crash:

[ RUN      ] BlobSimpleTest/0.TestReshapeZeroShape
*** Aborted at 1453388430 (unix time) try "date -d @1453388430" if you are using GNU date ***
PC: @     0x7ff80a5d596d caffe::Blob<>::Reshape()
*** SIGFPE (@0x7ff80a5d596d) received by PID 26958 (TID 0x7ff80aceca40) from PID 173889901; stack trace: ***
    @     0x7ff803ef1d40 (unknown)
    @     0x7ff80a5d596d caffe::Blob<>::Reshape()
    @           0xb4acd4 caffe::BlobSimpleTest_TestReshapeZeroShape_Test<>::TestBody()
    @           0xd7198b testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @           0xd6d092 testing::internal::HandleExceptionsInMethodIfSupported<>()
    @           0xd5a4a9 testing::Test::Run()
    @           0xd5ac42 testing::TestInfo::Run()
    @           0xd5b230 testing::TestCase::Run()
    @           0xd600ba testing::internal::UnitTestImpl::RunAllTests()
    @           0xd729be testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @           0xd6dcbd testing::internal::HandleExceptionsInMethodIfSupported<>()
    @           0xd5ee4e testing::UnitTest::Run()
    @           0xa6f1eb main
    @     0x7ff803edcec5 (unknown)
    @           0x97c5c9 (unknown)
    @                0x0 (unknown)
Floating point exception (core dumped)

What is the expected behavior for reshaping to zero?

@seanbell
Copy link

seanbell commented Mar 1, 2016

I think zero-sized blobs weren't contemplated in the current design. If you reshape to zero you get a user-unfriendly exception.

In general, I think it makes sense to allow zero-sized blobs, and to return null when grabbing the data pointer, instead of throwing the exception during Reshape (which is what happens now).

@shelhamer do you have an opinion on this issue?

@elezar
Copy link
Contributor Author

elezar commented May 6, 2016

I think this may have been addressed in #4101. I will have a look as soon as I get a chance.

@jeffdonahue
Copy link
Contributor

Yes, I'm pretty sure this was the bug that #4101 fixes. (Please comment if you find otherwise though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants