somaticio / tensorflow.rb

tensorflow for ruby
BSD 3-Clause "New" or "Revised" License
829 stars 63 forks source link

Fix a segfault in Session run #98

Closed AshtonO closed 7 years ago

AshtonO commented 7 years ago

Errors were ignored in the C++ implementation of Session_Run, which meant that the ruby code could segfault as it would try to continue on after a failed run.

This fix ensures Session_Run will throw an error that can be caught in ruby to avoid segfaulting for cases like passing in a tensor with an improper shape.

AshtonO commented 7 years ago

I also just added another fix for a potential Seg Fault. The graph.operation function previously said it would return nil if an operation didn't exist in the graph. However, all it did was warn and still create an operation with a null pointer.

This fix returns nil properly if an operation doesn't exist so a caller can see this and not call SessionRun using a null pointer initialized operation.

AshtonO commented 7 years ago

Added one more commit to fix improper strings from being returned. I noticed the string addition test in graph_spec.rb would occasionally fail and return things like: TensorflowRubyh instead of TensorflowRuby.

This fix makes sure these extra erroneous characters are ignored.

arafatkatze commented 7 years ago

@AshtonO T While developing the gem I did across this issue a few times but I didn't really think through this.
I am glad you wrote a fix. Thanks a lot for this.