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

Unchecked input for SP compute crashes program #1388

Open
breznak opened this issue Jan 12, 2018 · 4 comments
Open

Unchecked input for SP compute crashes program #1388

breznak opened this issue Jan 12, 2018 · 4 comments

Comments

@breznak
Copy link
Member

breznak commented Jan 12, 2018

the compute in SP void compute(UInt input[], bool learn, UInt output[]);
unfortunately, the data are passed as UInt* (typically from vector.data() with no way of checking the correct array sizes!

The check would be quite simple:
sp.getNumInputs() == input.size() && sp.getNumColumns() == out.size()

but we pass the pointer T* and cannot reconstruct the array properly, we cannot know the sizes of input parameters to compute()!

Providing a wrong size -smaller- (large is ok) crashes the program.

@breznak
Copy link
Member Author

breznak commented Jan 12, 2018

@scottpurdy is there something we can do about this? We've discussed this long ago, a solution would be (a bigger refactor) to use vector/std::array for compute()'s params; but you've mentioned performance reasons, does it still hold, or is there a way around it? (passing &vector)?

@breznak
Copy link
Member Author

breznak commented Jan 12, 2018

Similar issue on python-bindings side is #1385

@scottpurdy
Copy link
Contributor

I think it is fine to require the caller to pass the right size array as long as it is documented. It would be nice to use sparse representations everywhere rather than passing UInt32 dense arrays that just contain binary values but that would be a somewhat involved refactor that I don't think we have the stomach for right now (would really require a lot of time from @lscheinkman )

@breznak
Copy link
Member Author

breznak commented Jan 12, 2018

nice to use sparse representations everywhere rather than passing UInt32 dense arrays that just contain binary values ...

agreed. But it's nice to hear the notion, esp since the discussed community nupic.core fork, I think the (eigen) sparse repr. all round the codebase would be the way forward.

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

Successfully merging a pull request may close this issue.

2 participants