René's URL Explorer Experiment


Title: Exceptions in constructors causes v8 GC to fail with access violations · Issue #635 · nodejs/node-addon-api · GitHub

Open Graph Title: Exceptions in constructors causes v8 GC to fail with access violations · Issue #635 · nodejs/node-addon-api

X Title: Exceptions in constructors causes v8 GC to fail with access violations · Issue #635 · nodejs/node-addon-api

Description: Hey folks, If an exception is thrown from inside a constructor it seems it causes v8 GC to fail with an access violation in this case below. I am starting to think that this is caused by ObjectWrap::FinalizeCallback being called when ...

Open Graph Description: Hey folks, If an exception is thrown from inside a constructor it seems it causes v8 GC to fail with an access violation in this case below. I am starting to think that this is caused by ObjectWrap...

X Description: Hey folks, If an exception is thrown from inside a constructor it seems it causes v8 GC to fail with an access violation in this case below. I am starting to think that this is caused by ObjectWrap...

Opengraph URL: https://github.com/nodejs/node-addon-api/issues/635

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Exceptions in constructors causes v8 GC to fail with access violations","articleBody":"Hey folks,\r\nIf an exception is thrown from inside a constructor it seems it causes v8 GC to fail with an access violation in this case below. I am starting to think that this is caused by ```ObjectWrap\u003cT\u003e::FinalizeCallback``` being called when it shouldn't be.\r\n\r\nHere is the example code if you want to try it out quickly https://github.com/blagoev/node-addon-examples/commit/351752fab1b93068aaf84a9cc52d086170778f74\r\n\r\nThe highlights are these.\r\n\r\nThere is a static factory function on the exposed object\r\n\r\n```C++\r\nNapi::Value create(const Napi::CallbackInfo\u0026 info) {\r\n\tNapi::EscapableHandleScope scope(info.Env());\r\n\tNapi::Value val = MyObject::constructor.New({}); //this will throw an exception\r\n\r\n\treturn scope.Escape(info.Env().Undefined());\r\n}\r\n```\r\n\r\nthen the ctor throws some error\r\n\r\n```C++\r\nMyObject::MyObject(const Napi::CallbackInfo\u0026 info)\r\n\t: Napi::ObjectWrap\u003cMyObject\u003e(info) {\r\n\tNapi::Env env = info.Env();\r\n\tNapi::HandleScope scope(env);\r\n\tthrow Napi::Error::New(env, \"TEST\");\r\n......\r\n```\r\n\r\nand we have this private field in the class\r\n```C++\r\nstruct Data {\r\n};\r\n\r\nclass MyObject : public Napi::ObjectWrap\u003cMyObject\u003e {\r\nprivate:\r\n\tstd::shared_ptr\u003cData\u003e m_data;\r\n....\r\n```\r\n\r\nand this is the JS code that tries to call that\r\n```JavaScript\r\nvar addon = require('bindings')('addon');\r\ntry {\r\n    var obj = addon.MyObject.create();\r\n    }\r\n    catch (e) {\r\n        console.error(\"Incorrect expected exception message:\" + e.message);\r\n    }\r\n  \r\n    global.gc()\r\n    global.gc()\r\n    global.gc()\r\n```\r\n\r\nthen there is an exception here \r\n\r\n```\r\n\u003e\taddon.node!std::_Ref_count_base::_Decref() Line 845\tC++\r\n \taddon.node!std::_Ptr_base\u003cData\u003e::_Decref() Line 1122\tC++\r\n \taddon.node!std::shared_ptr\u003cData\u003e::~shared_ptr\u003cData\u003e() Line 1403\tC++\r\n \taddon.node!MyObject::~MyObject()\tC++\r\n \taddon.node!MyObject::`scalar deleting destructor'(unsigned int)\tC++\r\n \taddon.node!Napi::ObjectWrap\u003cMyObject\u003e::FinalizeCallback(napi_env__ * __formal, void * data, void * __formal) Line 3433\tC++\r\n \tnode.exe!`anonymous namespace'::v8impl::Reference::SecondPassCallback(const v8::WeakCallbackInfo\u003c`anonymous namespace'::v8impl::Reference\u003e \u0026 data) Line 496\tC++\r\n \t[Inline Frame] node.exe!v8::internal::GlobalHandles::PendingPhantomCallback::Invoke(v8::internal::Isolate *) Line 905\tC++\r\n \tnode.exe!v8::internal::GlobalHandles::InvokeSecondPassPhantomCallbacks(std::vector\u003cv8::internal::GlobalHandles::PendingPhantomCallback,std::allocator\u003cv8::internal::GlobalHandles::PendingPhantomCallback\u003e\u003e * callbacks, v8::internal::Isolate * isolate) Line 772\tC++\r\n \tnode.exe!v8::internal::GlobalHandles::DispatchPendingPhantomCallbacks(bool synchronous_second_pass) Line 881\tC++\r\n \tnode.exe!v8::internal::GlobalHandles::PostGarbageCollectionProcessing(v8::internal::GarbageCollector collector, const v8::GCCallbackFlags gc_callback_flags) Line 930\tC++\r\n \tnode.exe!v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector collector, const v8::GCCallbackFlags gc_callback_flags) Line 1775\tC++\r\n \tnode.exe!v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace space, v8::internal::GarbageCollectionReason gc_reason, const v8::GCCallbackFlags gc_callback_flags) Line 1392\tC++\r\n \t[Inline Frame] node.exe!v8::internal::Heap::CollectAllGarbage(int) Line 1156\tC++\r\n \tnode.exe!v8::Isolate::RequestGarbageCollectionForTesting(v8::Isolate::GarbageCollectionType type) Line 8273\tC++\r\n \tnode.exe!v8::internal::GCExtension::GC(const v8::FunctionCallbackInfo\u003cv8::Value\u003e \u0026 args) Line 26\tC++\r\n \tnode.exe!v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo * handler) Line 95\tC++\r\n \tnode.exe!v8::internal::`anonymous namespace'::HandleApiCallHelper\u003c0\u003e(v8::internal::Isolate * isolate, v8::internal::Handle\u003cv8::internal::HeapObject\u003e new_target, v8::internal::Handle\u003cv8::internal::HeapObject\u003e fun_data, v8::internal::Handle\u003cv8::internal::FunctionTemplateInfo\u003e receiver, v8::internal::Handle\u003cv8::internal::Object\u003e args, v8::internal::BuiltinArguments) Line 111\tC++\r\n \tnode.exe!v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments args, v8::internal::Isolate * isolate) Line 139\tC++\r\n \tnode.exe!v8::internal::Builtin_HandleApiCall(int args_length, v8::internal::Object * * args_object, v8::internal::Isolate * isolate) Line 127\tC++\r\n\r\n```\r\n\r\n**Note: you need to expose v8 GC for that to work with**\r\n```\r\nnode --expose_gc addon.js\r\n```\r\n\r\n\r\n\r\nIt seems to me this is cause the ```ObjectWrap\u003cT\u003e::FinalizeCallback``` is called but the native object did not get constructed correctly (ie the native object's ctor did not complete). Or is it that my assumption is wrong. \r\n\r\ncheers","author":{"url":"https://github.com/blagoev","@type":"Person","name":"blagoev"},"datePublished":"2019-12-16T18:40:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/635/node-addon-api/issues/635"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2f5c244a-eccf-4f63-68f6-8856691756e3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8960:47423:57F8F7C:7BDA4DD:6A4FF106
html-safe-nonce58489a1451eb5dd362441a73a7e8493e9a2568231fb893e52ad9451677de0de6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTYwOjQ3NDIzOjU3RjhGN0M6N0JEQTRERDo2QTRGRjEwNiIsInZpc2l0b3JfaWQiOiIzODYwMTMyMDY4NzM2MzMwMzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac045423ef82ed07c2c57eb1393abfd3f157f55a076078544cfd51cff98ad9dd13
hovercard-subject-tagissue:538584426
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node-addon-api/635/issue_layout
twitter:imagehttps://opengraph.githubassets.com/debca7f20893a225b8626ec2b4b8988b6e1e1c85e20fef708b0dce2d555b0052/nodejs/node-addon-api/issues/635
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/debca7f20893a225b8626ec2b4b8988b6e1e1c85e20fef708b0dce2d555b0052/nodejs/node-addon-api/issues/635
og:image:altHey folks, If an exception is thrown from inside a constructor it seems it causes v8 GC to fail with an access violation in this case below. I am starting to think that this is caused by ObjectWrap...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameblagoev
hostnamegithub.com
expected-hostnamegithub.com
None19b98c3d9767bb8a56238a89ff8401d1cbdf3bc5c353799aacf49fe6c76b4b7c
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node-addon-api git https://github.com/nodejs/node-addon-api.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id81384578
octolytics-dimension-repository_nwonodejs/node-addon-api
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81384578
octolytics-dimension-repository_network_root_nwonodejs/node-addon-api
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef7e270be010aa4de2871991025fbb97f3afe2bcb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node-addon-api/issues/635#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode-addon-api%2Fissues%2F635
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode-addon-api%2Fissues%2F635
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode-addon-api
Reloadhttps://github.com/nodejs/node-addon-api/issues/635
Reloadhttps://github.com/nodejs/node-addon-api/issues/635
Reloadhttps://github.com/nodejs/node-addon-api/issues/635
Please reload this pagehttps://github.com/nodejs/node-addon-api/issues/635
nodejs https://github.com/nodejs
node-addon-apihttps://github.com/nodejs/node-addon-api
Please reload this pagehttps://github.com/nodejs/node-addon-api/issues/635
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode-addon-api
Fork 500 https://github.com/login?return_to=%2Fnodejs%2Fnode-addon-api
Star 2.4k https://github.com/login?return_to=%2Fnodejs%2Fnode-addon-api
Code https://github.com/nodejs/node-addon-api
Issues 10 https://github.com/nodejs/node-addon-api/issues
Pull requests 4 https://github.com/nodejs/node-addon-api/pulls
Actions https://github.com/nodejs/node-addon-api/actions
Projects https://github.com/nodejs/node-addon-api/projects
Wiki https://github.com/nodejs/node-addon-api/wiki
Security and quality 0 https://github.com/nodejs/node-addon-api/security
Insights https://github.com/nodejs/node-addon-api/pulse
Code https://github.com/nodejs/node-addon-api
Issues https://github.com/nodejs/node-addon-api/issues
Pull requests https://github.com/nodejs/node-addon-api/pulls
Actions https://github.com/nodejs/node-addon-api/actions
Projects https://github.com/nodejs/node-addon-api/projects
Wiki https://github.com/nodejs/node-addon-api/wiki
Security and quality https://github.com/nodejs/node-addon-api/security
Insights https://github.com/nodejs/node-addon-api/pulse
Exceptions in constructors causes v8 GC to fail with access violationshttps://github.com/nodejs/node-addon-api/issues/635#top
https://github.com/blagoev
blagoevhttps://github.com/blagoev
on Dec 16, 2019https://github.com/nodejs/node-addon-api/issues/635#issue-538584426
blagoev/node-addon-examples@351752fhttps://github.com/blagoev/node-addon-examples/commit/351752fab1b93068aaf84a9cc52d086170778f74
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.