{"action":"opened","issue":{"url":"https://api.github.com/repos/intel-iot-devkit/upm/issues/172","labels_url":"https://api.github.com/repos/intel-iot-devkit/upm/issues/172/labels{/name}","comments_url":"https://api.github.com/repos/intel-iot-devkit/upm/issues/172/comments","events_url":"https://api.github.com/repos/intel-iot-devkit/upm/issues/172/events","html_url":"https://github.com/intel-iot-devkit/upm/issues/172","id":69642608,"number":172,"title":"SSD1327: Segfault when calling the draw method with incorrect arguments from python","user":{"login":"vvvverre","id":5421677,"avatar_url":"https://avatars.githubusercontent.com/u/5421677?v=3","gravatar_id":"","url":"https://api.github.com/users/vvvverre","html_url":"https://github.com/vvvverre","followers_url":"https://api.github.com/users/vvvverre/followers","following_url":"https://api.github.com/users/vvvverre/following{/other_user}","gists_url":"https://api.github.com/users/vvvverre/gists{/gist_id}","starred_url":"https://api.github.com/users/vvvverre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vvvverre/subscriptions","organizations_url":"https://api.github.com/users/vvvverre/orgs","repos_url":"https://api.github.com/users/vvvverre/repos","events_url":"https://api.github.com/users/vvvverre/events{/privacy}","received_events_url":"https://api.github.com/users/vvvverre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-20T17:46:38Z","updated_at":"2015-04-20T17:46:38Z","closed_at":null,"body":"When calling ssd1327.draw() from python the library segfaults if the first argument is not of type lcd.uint8Array. It would be much nicer if the library returns an error when it finds an unexpected type, instead of carrying on with a null pointer (see data in the backtrace below) and causing a guaranteed segfault down the line. Ideally passing native python types would work, but I think this would require the use of SWIG typemaps?\r\n\r\nThe following is a reproducer:\r\n\r\n>Python 2.7.3 (default, Mar 31 2015, 11:37:49) \r\n>[GCC 4.8.2] on linux2\r\n>Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n> \\>\\>\\> import pyupm_i2clcd as lcd\r\n> \\>\\>\\> x = lcd.SSD1327(0);\r\n> \\>\\>\\> x.draw(\"\\x55\", 1); \r\n>Program received signal SIGSEGV, Segmentation fault.\r\n>0xb7efe7b3 in upm::SSD1327::draw (this=0x805be00, data=0x0, bytes=1) at >/home/root/git/upm/src/lcd/ssd1327.cxx:146\r\n>146\t            uint8_t bitOne = (data[row] << col) & 0x80;\r\n\r\nA backtrace from gdb is shown below:\r\n\r\n>(gdb) bt\r\n>#0  0xb7efe7b3 in upm::SSD1327::draw (this=0x805be00, data=0x0, bytes=1) at /home/root/git/upm/src/lcd/ssd1327.cxx:146\r\n>\\#1  0xb7ef9573 in _wrap_SSD1327_draw (args=0xb7f4d8ec) at /home/root/git/upm/build/src/lcd/pyupm_i2clcdPYTHON_wrap.cxx:5325\r\n>\\#2  0x4a163aaf in PyCFunction_Call () from /usr/lib/libpython2.7.so.1.0\r\n>\\#3  0x4a1c3dd4 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0\r\n>\\#4  0x4a1c3a7d in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0\r\n>\\#5  0x4a1c46c1 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0\r\n>\\#6  0x4a1c4843 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0\r\n>\\#7  0x4a1de369 in ?? () from /usr/lib/libpython2.7.so.1.0\r\n>\\#8  0x4a1e0536 in PyRun_InteractiveOneFlags () from /usr/lib/libpython2.7.so.1.0\r\n>\\#9  0x4a1e0713 in PyRun_InteractiveLoopFlags () from /usr/lib/libpython2.7.so.1.0\r\n>\\#10 0x4a1e0d38 in PyRun_AnyFileExFlags () from /usr/lib/libpython2.7.so.1.0\r\n>\\#11 0x4a1f07cc in Py_Main () from /usr/lib/libpython2.7.so.1.0\r\n>\\#12 0x08048567 in main ()\r\n"}}