{"action":"created","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/4042","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/4042/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/4042/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/4042/events","html_url":"https://github.com/kripken/emscripten/issues/4042","id":126982021,"number":4042,"title":"longjmp not caught when being called from emscripten_set_main_loop","user":{"login":"gyf304","id":7296537,"avatar_url":"https://avatars.githubusercontent.com/u/7296537?v=3","gravatar_id":"","url":"https://api.github.com/users/gyf304","html_url":"https://github.com/gyf304","followers_url":"https://api.github.com/users/gyf304/followers","following_url":"https://api.github.com/users/gyf304/following{/other_user}","gists_url":"https://api.github.com/users/gyf304/gists{/gist_id}","starred_url":"https://api.github.com/users/gyf304/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyf304/subscriptions","organizations_url":"https://api.github.com/users/gyf304/orgs","repos_url":"https://api.github.com/users/gyf304/repos","events_url":"https://api.github.com/users/gyf304/events{/privacy}","received_events_url":"https://api.github.com/users/gyf304/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-15T23:52:22Z","updated_at":"2016-01-16T21:28:40Z","closed_at":null,"body":"I commented the original code out and tried a fix. Not certain if is correct.\r\n\r\n```\r\n        },runIter:function (func) {\r\n          if (ABORT) return;\r\n          if (Module['preMainLoop']) {\r\n            var preRet = Module['preMainLoop']();\r\n            if (preRet === false) {\r\n              return; // |return false| skips a frame\r\n            }\r\n          }\r\n          try {\r\n            func();\r\n          } catch (e) {\r\n            if (e instanceof ExitStatus) {\r\n              return;\r\n            } else {\r\n              if (typeof e !== 'number' && e !== 'longjmp') throw e;\r\n                asm[\"setThrew\"](1, 0);\r\n              //if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);\r\n              //throw e;\r\n            }\r\n          }\r\n          if (Module['postMainLoop']) Module['postMainLoop']();\r\n        }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {\r\n        if (!Module[\"preloadPlugins\"]) Module[\"preloadPlugins\"] = []; // needs to exist even in workers\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/kripken/emscripten/issues/comments/172259270","html_url":"https://github.com/kripken/emscripten/issues/4042#issuecomment-172259270","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/4042","id":172259270,"user":{"login":"kripken","id":173661,"avatar_url":"https://avatars.githubusercontent.com/u/173661?v=3","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"created_at":"2016-01-16T21:28:40Z","updated_at":"2016-01-16T21:28:40Z","body":"Thanks, now I see.\r\n\r\nThe main loop is asynchronous - it's called from the JS event loop, later, after `main()` exits. That means that trying to jump back is an attempt to jump into a stack that has been unwound already, which is undefined behavior, that we don't support (there is no practical way to support it).\r\n\r\nI can't think of a good way to improve the error message here, but I'm open to suggestions."}}