Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Fix sp compute unchecked input #1389

Closed

Conversation

breznak
Copy link
Member

@breznak breznak commented Jan 12, 2018

  • add test for compute's incorrect sizes of input params
    • unit-test expected to crash crashes the whole build
    • check for correct sizes (need to get size of inputArray[] aka T*)

Fixes #1388

these fields are entered by user and must exactly match the Input, Columns
sizes.
Unfortunately, the array is passed as T* so getting the size will be tricky.
Copy link
Member Author

@breznak breznak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • added test
  • suggested runtime check inside SP
  • please see the Issue for discussion how to resolve this

// check size of input/output arrays
//TODO since c++17 there is std::size() in <iterator> for arrays
// NTA_ASSERT(this->getNumInputs() == std::vector<UInt>(inputArray).size()); //FIXME get size of the array (T*) ?
// NTA_ASSERT(this->getNumColumns() == sizeof(*activeArray)/sizeof(UInt));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we overcome that inputArray[] is of type T*? We need the size of the passed array.


EXPECT_NO_THROW(sp.compute(inputOK.data(), true, outOK.data()));
//FIXME EXPECT_ANY does not handle the malloc fail caused here, crashes!
//! EXPECT_ANY_THROW(sp.compute(inputFail.data(), true, outOK.data()));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test crashes (malloc) even though we know it'd crash and want to check for it. Is there a way how to achieve this?

@breznak
Copy link
Member Author

breznak commented Jan 19, 2018

Won't fix. Moved to htm-community#9

@breznak breznak closed this Jan 19, 2018
@breznak breznak deleted the fix_sp_compute_unchecked_input branch November 11, 2018 20:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant