{"action":"created","issue":{"url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/1006","repository_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport","labels_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/1006/labels{/name}","comments_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/1006/comments","events_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/1006/events","html_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/1006","id":188351007,"number":1006,"title":"Access violation after 2 or 3 successive writes","user":{"login":"Zensey","id":769152,"avatar_url":"https://avatars.githubusercontent.com/u/769152?v=3","gravatar_id":"","url":"https://api.github.com/users/Zensey","html_url":"https://github.com/Zensey","followers_url":"https://api.github.com/users/Zensey/followers","following_url":"https://api.github.com/users/Zensey/following{/other_user}","gists_url":"https://api.github.com/users/Zensey/gists{/gist_id}","starred_url":"https://api.github.com/users/Zensey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zensey/subscriptions","organizations_url":"https://api.github.com/users/Zensey/orgs","repos_url":"https://api.github.com/users/Zensey/repos","events_url":"https://api.github.com/users/Zensey/events{/privacy}","received_events_url":"https://api.github.com/users/Zensey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-09T20:59:14Z","updated_at":"2016-11-11T05:28:07Z","closed_at":null,"body":"SerialPort version: 4.0.5\r\nNodeJS Version: 4.5.1\r\nOperating System and Hardware Platform: Windows XP /7/8/10\r\n\r\nSummary:\r\nAfter migration to serialport@>=4 my program started:\r\n* to crash on Windows\r\n* to hang on Linux\r\n\r\nCrash condition:\r\n2 or 3 successive writes\r\n\r\nTest:\r\n```\r\nconst\r\n    co = require('co'),\r\n    log4js = require('log4js'),\r\n    SerialPort = require('serialport');\r\nvar logger = log4js.getLogger('test')\r\n\r\nfunction* test_v4 () {\r\n    var sp = new SerialPort('COM1', {baudRate: 9600, autoOpen: false})\r\n    yield cb => sp.open(cb)\r\n    for (var i = 1; i <= 5; i++) {\r\n        yield cb => sp.write(new Buffer([1, 2]), cb)\r\n        logger.info('>', i)\r\n    }\r\n}\r\nco(test_v4).then(function (res) {\r\n    logger.info('res >', res);\r\n    process.exit()\r\n}, function (err) {\r\n    logger.error(err.stack);\r\n});\r\n```\r\n\r\nOutput:\r\n```\r\nC:\\Shared\\test>node test\r\n[2016-11-09 23:45:54.285] [INFO] test - > 1\r\n[2016-11-09 23:45:54.301] [INFO] test - > 2\r\n\r\nC:\\Shared\\test>\r\n```\r\n\r\nAs you can see for-loop does not complete. \r\nOn serialport@3 it did.\r\n\r\n\r\nNtTrace:\r\n```\r\n...\r\n\u001B[32m[2016-11-09 23:17:56.637] [INFO] test - \u001B[39m> 2\r\nNtWriteFile( FileHandle=0x60, Event=0, ApcRoutine=null, ApcContext=null, IoStatusBlock=0xf4f178 [0/0x36], Buffer=0x25a180, Length=0x36, ByteOffset=null, Key=null ) => 0\r\nNtReleaseKeyedEvent( KeyedEventHandle=0, Key=0x405f870, Alertable=false, Timeout=null ) => 0\r\nNtWaitForKeyedEvent( KeyedEventHandle=0, Key=0x405f870, Alertable=false, Timeout=null ) => 0\r\nNtSetEvent( EventHandle=0x200, PrevState=null ) => 0\r\nNtWaitForSingleObject( Handle=0x200, Alertable=false, Timeout=null ) => 0\r\nNtCreateEvent( EventHandle=0x405f85c [0x210], DesiredAccess=DELETE|READ_CONTROL|WRITE_DAC|WRITE_OWNER|SYNCHRONIZE|0x3, ObjectAttributes=null, EventType=0 [NotificationEvent], InitialState=false ) => 0\r\nNtWriteFile( FileHandle=0x208, Event=0x210, ApcRoutine=null, ApcContext=0x405f8b0, IoStatusBlock=0x405f8b0, Buffer=0x25a1b8, Length=2, ByteOffset=0x405f840 [0], Key=null ) => 0x103 [997 'Протекает наложенное событие ввода/вывода.']\r\nNtReleaseKeyedEvent( KeyedEventHandle=0, Key=0x41af700, Alertable=false, Timeout=null ) => 0\r\nNtWaitForKeyedEvent( KeyedEventHandle=0, Key=0x41af700, Alertable=false, Timeout=null ) => 0\r\nNtWaitForSingleObject( Handle=0x210, Alertable=false, Timeout=null ) => 0\r\nNtClose( Handle=0x210 ) => 0\r\nNtSetEvent( EventHandle=0x200, PrevState=null ) => 0\r\nNtWaitForSingleObject( Handle=0x200, Alertable=false, Timeout=null ) => 0\r\nAccess violation at 00000000: Write to 00000000 (first chance)\r\nAccess violation at 00000000: Write to 00000000 (first chance)\r\nAccess violation at 00443D58: Write to FEEEFEEE (first chance)\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=0x22 [ProcessExecuteFlags], ProcessInformation=0x41af3fc, Length=4, ReturnLength=null ) => 0\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=0x22 [ProcessExecuteFlags], ProcessInformation=0x405f564, Length=4, ReturnLength=null ) => 0\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=0x24 [ProcessCookie], ProcessInformation=0x405f458, Length=4, ReturnLength=null ) => 0\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=0x24 [ProcessCookie], ProcessInformation=0x41af2f0, Length=4, ReturnLength=null ) => 0\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=7 [ProcessDebugPort], ProcessInformation=0x405f3d4, Length=4, ReturnLength=null ) => 0\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=7 [ProcessDebugPort], ProcessInformation=0x41af26c, Length=4, ReturnLength=null ) => 0\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=0x22 [ProcessExecuteFlags], ProcessInformation=0xf4f740, Length=4, ReturnLength=null ) => 0\r\nAccess violation at 74FFCB49: Write to 00000000 (last chance)\r\nAccess violation at 74FFCB49: Write to 00000000 (last chance)\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=0x24 [ProcessCookie], ProcessInformation=0xf4f634, Length=4, ReturnLength=null ) => 0\r\nNtQueryVirtualMemory( ProcessHandle=-1, BaseAddress=0xfeeefeee, MemoryInformationClass=0 [MemoryBasicInformation], MemoryInformation=0xf4f54c, Length=0x1c, ReturnLength=null ) => 0xc000000d [87 'Параметр задан неверно.']\r\nNtQueryInformationProcess( ProcessHandle=-1, ProcessInformationClass=7 [ProcessDebugPort], ProcessInformation=0xf4f5b0, Length=4, ReturnLength=null ) => 0\r\nAccess violation at 00443D58: Write to FEEEFEEE (last chance)\r\nThread 5236 exit code: 3221225477\r\nThread 6408 exit code: 3221225477\r\nThread 6184 exit code: 3221225477\r\nThread 6776 exit code: 3221225477\r\nThread 2560 exit code: 3221225477\r\nThread 4740 exit code: 3221225477\r\nThread 6980 exit code: 3221225477\r\nThread 4956 exit code: 3221225477\r\nThread 4700 exit code: 3221225477\r\nThread 5272 exit code: 3221225477\r\nProcess 3424 exit code: 3221225477\r\n```\r\nComplete [log](http://pastebin.ru/tdYaVI6a)\r\n\r\n\r\nWork-around:\r\nadd one of these lines after write\r\n``yield cb => sp.drain(cb)``\r\n``yield cb => setImmediate(cb, 0)``\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/comments/259884210","html_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/1006#issuecomment-259884210","issue_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/1006","id":259884210,"user":{"login":"reconbot","id":25966,"avatar_url":"https://avatars.githubusercontent.com/u/25966?v=3","gravatar_id":"","url":"https://api.github.com/users/reconbot","html_url":"https://github.com/reconbot","followers_url":"https://api.github.com/users/reconbot/followers","following_url":"https://api.github.com/users/reconbot/following{/other_user}","gists_url":"https://api.github.com/users/reconbot/gists{/gist_id}","starred_url":"https://api.github.com/users/reconbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reconbot/subscriptions","organizations_url":"https://api.github.com/users/reconbot/orgs","repos_url":"https://api.github.com/users/reconbot/repos","events_url":"https://api.github.com/users/reconbot/events{/privacy}","received_events_url":"https://api.github.com/users/reconbot/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T05:28:07Z","updated_at":"2016-11-11T05:28:07Z","body":"[Version 4.0.6 is Released](https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/tag/4.0.6) please give it a try and let me know if it fixes this."}}
{"actor":{"display_login":"reconbot"}}