Remove overflow and detect it if it happen again.
Don't read bad address. This fix a crash on some more strict driver/hardware.

Otherwise, it didn't cause other problems, as we reported the error to the user.

close gh-1814
Merge pull request #1817 from nouiz/crash

Remove overflow and detect it if it happen again.
fixed the division by zero.
fixed typos.
Merge pull request #1823 from caglar/cuda_ndarray_fix

Cuda ndarray fix