{"action":"closed","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/4837","repository_url":"https://api.github.com/repos/kripken/emscripten","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/4837/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/4837/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/4837/events","html_url":"https://github.com/kripken/emscripten/issues/4837","id":198974553,"number":4837,"title":"pwrite64 syscall crashes at run time","user":{"login":"atrosinenko","id":9654772,"avatar_url":"https://avatars.githubusercontent.com/u/9654772?v=3","gravatar_id":"","url":"https://api.github.com/users/atrosinenko","html_url":"https://github.com/atrosinenko","followers_url":"https://api.github.com/users/atrosinenko/followers","following_url":"https://api.github.com/users/atrosinenko/following{/other_user}","gists_url":"https://api.github.com/users/atrosinenko/gists{/gist_id}","starred_url":"https://api.github.com/users/atrosinenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atrosinenko/subscriptions","organizations_url":"https://api.github.com/users/atrosinenko/orgs","repos_url":"https://api.github.com/users/atrosinenko/repos","events_url":"https://api.github.com/users/atrosinenko/events{/privacy}","received_events_url":"https://api.github.com/users/atrosinenko/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-01-05T14:56:56Z","updated_at":"2017-01-14T18:47:59Z","closed_at":"2017-01-14T18:47:59Z","body":"The `pwrite64` syscall [references](https://github.com/kripken/emscripten/blob/master/src/library_syscall.js#L845) the `nbyte` variable while the `count` variable is probably assumed.\r\n\r\n## How to reproduce\r\n\r\nCompile this code\r\n\r\n```c\r\n#include <sys/types.h>\r\n#include <sys/stat.h>\r\n#include <fcntl.h>\r\n#include <stdio.h>\r\n#include <unistd.h>\r\n\r\nint main()\r\n{\r\n  char str[] = \"test abc\\n\";\r\n  int fd = open(\"test.txt\", O_WRONLY | O_CREAT);\r\n  fprintf(stderr, \"fd = %d\\n\", fd);\r\n  int ret = pwrite(fd, str, sizeof(str), 4);\r\n  fprintf(stderr, \"pwrite: %d\\n\", ret);\r\n  return 0;\r\n}\r\n```\r\n\r\nWhen run using `node test.js` it outputs:\r\n\r\n    fd = 3\r\n    [ReferenceError: nbyte is not defined]\r\n    [ReferenceError: nbyte is not defined]\r\n    \r\n    /home/old_home/trosinenko/tmp/bugs/pwrite/test.js:110\r\n          throw ex;\r\n          ^\r\n    abort({}) at Error\r\n        at jsStackTrace (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:1092:13)\r\n        at stackTrace (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:1109:12)\r\n        at abort (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:12237:44)\r\n        at ___syscall181 (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:4710:69)\r\n        at _pwrite (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:8454:8)\r\n        at _main (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:5017:8)\r\n        at Object.asm._main (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:11961:19)\r\n        at Object.callMain (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:12112:30)\r\n        at doRun (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:12172:60)\r\n        at run (/home/old_home/trosinenko/tmp/bugs/pwrite/test.js:12186:5)\r\n\r\n`emcc -v` output:\r\n\r\n    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.1\r\n    clang version 3.9.0 (https://github.com/kripken/emscripten-fastcomp-clang/ 7372fbdc769db28fd534454268f4b008e629464f) (https://github.com/kripken/emscripten-fastcomp/ 942a10fbb02f54866c3fc11d6fad119cc38f1e8f) (emscripten 1.37.1 : 1.37.1)\r\n    Target: x86_64-unknown-linux-gnu\r\n    Thread model: posix\r\n    InstalledDir: /home/trosinenko/soft/emsdk_portable/clang/fastcomp/build_incoming_64/bin\r\n    Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5\r\n    Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0\r\n    Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6\r\n    Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0\r\n    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9\r\n    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3\r\n    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5\r\n    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0\r\n    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6\r\n    Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0\r\n    Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0\r\n    Candidate multilib: .;@m64\r\n    Candidate multilib: 32;@m32\r\n    Candidate multilib: x32;@mx32\r\n    Selected multilib: .;@m64\r\n    INFO:root:(Emscripten: Running sanity checks)\r\n"}}
{"actor":{"display_login":"kripken"}}