{"action":"created","issue":{"url":"https://api.github.com/repos/svaarala/duktape/issues/476","labels_url":"https://api.github.com/repos/svaarala/duktape/issues/476/labels{/name}","comments_url":"https://api.github.com/repos/svaarala/duktape/issues/476/comments","events_url":"https://api.github.com/repos/svaarala/duktape/issues/476/events","html_url":"https://github.com/svaarala/duktape/issues/476","id":120282166,"number":476,"title":"Custom allocator failures cannot handle safe calls;","user":{"login":"jsas","id":1351492,"avatar_url":"https://avatars.githubusercontent.com/u/1351492?v=3","gravatar_id":"","url":"https://api.github.com/users/jsas","html_url":"https://github.com/jsas","followers_url":"https://api.github.com/users/jsas/followers","following_url":"https://api.github.com/users/jsas/following{/other_user}","gists_url":"https://api.github.com/users/jsas/gists{/gist_id}","starred_url":"https://api.github.com/users/jsas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsas/subscriptions","organizations_url":"https://api.github.com/users/jsas/orgs","repos_url":"https://api.github.com/users/jsas/repos","events_url":"https://api.github.com/users/jsas/events{/privacy}","received_events_url":"https://api.github.com/users/jsas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/svaarala/duktape/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-12-03T22:12:51Z","updated_at":"2015-12-04T11:57:49Z","closed_at":null,"body":"When  a custom allocator is used, there is no way to tell if the duktape handle_error flag is set so that an allocation for the error can occur. This makes \"safe call\" wrappers unable to catch allocation errors (because an error cannot be pushed onto the stack, resulting in the fatal_handler being called.\r\n\r\nIs it feasible to expose some properties of the current state of the heap? For example, the internal handling_error flag. In that case, my custom allocator could detect if duktape is trying to allocate memory for an error to push onto the stack."},"comment":{"url":"https://api.github.com/repos/svaarala/duktape/issues/comments/161950350","html_url":"https://github.com/svaarala/duktape/issues/476#issuecomment-161950350","issue_url":"https://api.github.com/repos/svaarala/duktape/issues/476","id":161950350,"user":{"login":"fatcerberus","id":4097841,"avatar_url":"https://avatars.githubusercontent.com/u/4097841?v=3","gravatar_id":"","url":"https://api.github.com/users/fatcerberus","html_url":"https://github.com/fatcerberus","followers_url":"https://api.github.com/users/fatcerberus/followers","following_url":"https://api.github.com/users/fatcerberus/following{/other_user}","gists_url":"https://api.github.com/users/fatcerberus/gists{/gist_id}","starred_url":"https://api.github.com/users/fatcerberus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatcerberus/subscriptions","organizations_url":"https://api.github.com/users/fatcerberus/orgs","repos_url":"https://api.github.com/users/fatcerberus/repos","events_url":"https://api.github.com/users/fatcerberus/events{/privacy}","received_events_url":"https://api.github.com/users/fatcerberus/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T11:57:49Z","updated_at":"2015-12-04T11:57:49Z","body":"Yet another solution would be to have two callbacks: one to allocate memory during normal bytecode execution (which should always be sandboxed), and another to allocate memory for internal Duktape structures (which might be more useful to allow lenience).  If the app needs both of these to be sandboxed, it will just use the same function for both, else it can provide separate functions."}}