{"action":"created","issue":{"url":"https://api.github.com/repos/rsta2/circle/issues/87","repository_url":"https://api.github.com/repos/rsta2/circle","labels_url":"https://api.github.com/repos/rsta2/circle/issues/87/labels{/name}","comments_url":"https://api.github.com/repos/rsta2/circle/issues/87/comments","events_url":"https://api.github.com/repos/rsta2/circle/issues/87/events","html_url":"https://github.com/rsta2/circle/issues/87","id":377173806,"node_id":"MDU6SXNzdWUzNzcxNzM4MDY=","number":87,"title":"Serial.Read() randomly crashing","user":{"login":"stephanedamo","id":17436316,"node_id":"MDQ6VXNlcjE3NDM2MzE2","avatar_url":"https://avatars0.githubusercontent.com/u/17436316?v=4","gravatar_id":"","url":"https://api.github.com/users/stephanedamo","html_url":"https://github.com/stephanedamo","followers_url":"https://api.github.com/users/stephanedamo/followers","following_url":"https://api.github.com/users/stephanedamo/following{/other_user}","gists_url":"https://api.github.com/users/stephanedamo/gists{/gist_id}","starred_url":"https://api.github.com/users/stephanedamo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephanedamo/subscriptions","organizations_url":"https://api.github.com/users/stephanedamo/orgs","repos_url":"https://api.github.com/users/stephanedamo/repos","events_url":"https://api.github.com/users/stephanedamo/events{/privacy}","received_events_url":"https://api.github.com/users/stephanedamo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-04T17:15:47Z","updated_at":"2018-11-05T12:49:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hello,\r\n\r\nI've noticed after a lot of investigations that calling Serial.Read() may crash the Raspberry PI 3B+ (happens anywhere between 1min / 2 hours in my program).\r\nIt's random, but a way of making it crash very fast is to send serial data to the raspberry and call Read() in a loop without the program doing other things, like in this minimal example : \r\n[main.zip](https://github.com/rsta2/circle/files/2546028/main.zip)\r\nI test it using MIDI data (sent by my computer through an USB/MIDI adapter, then fed into an optocoupler and some resistors then to the RPI's GPIO). I use this file because it has a lot of events so it also helps crashing it faster : \r\n[Goden_Axe_-_Stage_1.zip](https://github.com/rsta2/circle/files/2546041/Goden_Axe_-_Stage_1.zip)\r\n\r\n**If no serial data is sent, Read() is fine and will never crash. The problems shows only when there is a least one byte to read.**\r\n\r\nIf you uncomment line 45 to make Read() calls less frequent, it will take more time for it to crash.\r\n\r\nIt's not dependant of the total bytes received, in my real program it crashed anywhere between 300KB/3MB of data received.\r\n\r\nWhen it crashes, either the Raspeberry freezes, or the error is catch by your ExceptionHandler and it's always a Prefetch Abort error, FSR = 0xD (permission error according to the ARM docs)\r\n\r\nI've tried your example #29 (miniorgan) and managed to crash it (I just rewrote the GetChunk with a loop that write zero's so it's not much busy and can crash in less than one minute). I don't get much Prefetch Abort errors here but freezes and sometimes this message just before : \r\n\r\n> interrupt.cpp(122): assertion failed: FIQData.pHandler == 0\r\n\r\n\r\nDo you know what may happen ?\r\nI can do more tests if you want, since it may not be that easy for you to setup."},"comment":{"url":"https://api.github.com/repos/rsta2/circle/issues/comments/435862318","html_url":"https://github.com/rsta2/circle/issues/87#issuecomment-435862318","issue_url":"https://api.github.com/repos/rsta2/circle/issues/87","id":435862318,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTg2MjMxOA==","user":{"login":"rsta2","id":9377920,"node_id":"MDQ6VXNlcjkzNzc5MjA=","avatar_url":"https://avatars1.githubusercontent.com/u/9377920?v=4","gravatar_id":"","url":"https://api.github.com/users/rsta2","html_url":"https://github.com/rsta2","followers_url":"https://api.github.com/users/rsta2/followers","following_url":"https://api.github.com/users/rsta2/following{/other_user}","gists_url":"https://api.github.com/users/rsta2/gists{/gist_id}","starred_url":"https://api.github.com/users/rsta2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsta2/subscriptions","organizations_url":"https://api.github.com/users/rsta2/orgs","repos_url":"https://api.github.com/users/rsta2/repos","events_url":"https://api.github.com/users/rsta2/events{/privacy}","received_events_url":"https://api.github.com/users/rsta2/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T12:49:55Z","updated_at":"2018-11-05T12:49:55Z","author_association":"OWNER","body":"Yes, the same problem arose here with `-O2`. I did some more tests and maybe I found something. Can you please replace the file *lib/synchronize.cpp* with the attached file and do some tests then (be sure to have the latest Circle version from the master branch). With the modification contained in this file, your test program was running for one hour here without problems, while receiving 14 MByte data.\r\n\r\n[synchronize.cpp.zip](https://github.com/rsta2/circle/files/2548402/synchronize.cpp.zip)\r\n"}}
{"actor":{"display_login":"rsta2"}}