René's URL Explorer Experiment


Title: Worker teardown: AB-BA deadlock between main and worker V8 isolate locks (constrained-core/CI) · Issue #397 · NativeScript/ios · GitHub

Open Graph Title: Worker teardown: AB-BA deadlock between main and worker V8 isolate locks (constrained-core/CI) · Issue #397 · NativeScript/ios

X Title: Worker teardown: AB-BA deadlock between main and worker V8 isolate locks (constrained-core/CI) · Issue #397 · NativeScript/ios

Description: Summary The runtime unit-test suite intermittently deadlocks during the TNS Workers "no crash during or after runtime teardown on iOS" worker stress spec. It does not reproduce on multi-core dev machines, but reproduces reliably on the c...

Open Graph Description: Summary The runtime unit-test suite intermittently deadlocks during the TNS Workers "no crash during or after runtime teardown on iOS" worker stress spec. It does not reproduce on multi-core dev ma...

X Description: Summary The runtime unit-test suite intermittently deadlocks during the TNS Workers "no crash during or after runtime teardown on iOS" worker stress spec. It does not reproduce on multi-c...

Opengraph URL: https://github.com/NativeScript/ios/issues/397

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Worker teardown: AB-BA deadlock between main and worker V8 isolate locks (constrained-core/CI)","articleBody":"## Summary\n\nThe runtime unit-test suite intermittently **deadlocks** during the `TNS Workers` \"no crash during or after runtime teardown on iOS\" worker stress spec. It does **not** reproduce on multi-core dev machines, but reproduces reliably on the constrained CI runner. Root cause is a genuine **AB-BA deadlock between two V8 isolate locks** (the main isolate and a worker isolate) — a real (if rare) latent runtime issue, not just a test artifact.\n\nThe spec is **quarantined at the harness level** (a `specFilter` entry in `TestRunner/app/Infrastructure/Jasmine/jasmine-2.0.1/boot.js`) so CI is green; this issue tracks the proper runtime fix and re-enabling the spec.\n\n## The deadlock (proven from native stacks)\n\nCaptured by sampling the hung `TestRunner` app process on CI (10 snapshots, identical cycle in each):\n\n**Main thread** — holds the **main** isolate lock (running JS), is in the spec's 1ms `setTimeout` loop posting `'send-to-worker'`:\n\n```\n__NSFireTimer → JS produceMessageInLoop\n  → -[NSNotificationCenter postNotificationName:object:userInfo:]\n    → __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__   (worker's queue:nil observer block)\n      → tns::ArgConverter::MethodCallback → v8::Locker::Locker(workerIsolate)\n        → __psynch_mutexwait        // BLOCKED waiting for the worker isolate lock\n```\n\n**Worker thread** — holds **its own** isolate lock (loading `TeardownCrashWorker.js`), triggers a main-extended class's `+initialize`:\n\n```\nWorkerWrapper::BackgroundLooper → Runtime::RunModule → ... → ObjC msgSend\n  → initializeNonMetaClass → CALLING_SOME_+initialize_METHOD\n    → block in ClassBuilder::RegisterNativeTypeScriptExtendsFunction (NativeScript/runtime/ClassBuilder.mm:266)\n      → v8::Locker::Locker(mainIsolate)\n        → __psynch_mutexwait        // BLOCKED waiting for the main isolate lock\n```\n\n(A third thread is a secondary victim, blocked on the ObjC class-initialization `os_unfair_lock` held by the stuck worker.)\n\nSo: **main holds main-lock / wants worker-lock; worker holds worker-lock / wants main-lock.** Neither can proceed. It only manifests when those two windows overlap, which is why fast machines miss it and constrained CI hits it.\n\n## Why each side crosses isolates\n\n- **main → worker**: the worker registered an `NSNotificationCenter` observer with a **nil queue**, so the block runs synchronously on the *posting* (main) thread; NativeScript marshals it into the worker isolate, taking the worker's `v8::Locker`.\n- **worker → main**: `ClassBuilder::RegisterNativeTypeScriptExtendsFunction` installs a `+initialize` IMP that captures the **defining** isolate and does `v8::Locker locker(isolate)` ([ClassBuilder.mm:262-296](../blob/main/NativeScript/runtime/ClassBuilder.mm#L262)). `+initialize` fires lazily on whichever thread first messages the class — here a worker thread first-touches a main-defined extended class, so the worker runs `+initialize` and locks the **main** isolate.\n\n## Reproduction conditions\n\n- Constrained cores (CI runner; not reproducible on many-core dev machines).\n- A worker observing a main-thread notification with a nil queue, while the worker is still initializing/first-touching a main-isolate-extended class.\n- This pattern is unusual but **possible in production**, so the fix matters beyond CI.\n\n## Candidate fix directions (both deep; need a real repro harness + review)\n\n1. **worker → main side** — avoid running a foreign isolate's `+initialize` from a worker thread (e.g. seed/force initialization on the defining isolate's thread at registration time, or make the IMP defer to the defining isolate's runloop). Risk: class-extension / `ObjCExposedMethods` timing.\n2. **main → worker side** — invoke a worker-owned callback (e.g. a nil-queue notification block) on the worker's runloop instead of synchronously on the posting thread. Risk: changes synchronous-callback semantics app-wide.\n\n## Diagnostics\n\nNative-stack capture on hang is now wired into CI (`.github/scripts/sample-hung-app.sh`, uploaded as the `test-diagnostics` artifact), and the in-app Jasmine progress beacon reports the last suite to the XCTest harness — so any future suite hang is self-diagnosing.\n","author":{"url":"https://github.com/NathanWalker","@type":"Person","name":"NathanWalker"},"datePublished":"2026-06-27T16:37:44Z","url":"https://github.com/NativeScript/ios/issues/397"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4ebaed58-4ca9-2e27-6ec9-36eff137af4c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE282:3DD488:19E4F68:20D7D02:6B014C2F
html-safe-nonce548b02cad4b542cc4a61d379d8f11237a664ba18c7ec2f257a16ce84b7483afe
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjgyOjNERDQ4ODoxOUU0RjY4OjIwRDdEMDI6NkIwMTRDMkYiLCJ2aXNpdG9yX2lkIjoiNDM2MDY4NDYwODU0ODU2NzUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb8d54378487eb41ff464155e0888555125abf4e378b8d554aa62d0400383188d
hovercard-subject-tagissue:4759117197
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/NativeScript/ios/397/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5731edf1fe4020f0b407ffc441a3f26e3827dca0627c3d6532b60f3d8bf11b24/NativeScript/ios/issues/397
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5731edf1fe4020f0b407ffc441a3f26e3827dca0627c3d6532b60f3d8bf11b24/NativeScript/ios/issues/397
og:image:altSummary The runtime unit-test suite intermittently deadlocks during the TNS Workers "no crash during or after runtime teardown on iOS" worker stress spec. It does not reproduce on multi-core dev ma...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameNathanWalker
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/NativeScript/ios git https://github.com/NativeScript/ios.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id172934359
octolytics-dimension-repository_nwoNativeScript/ios
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id172934359
octolytics-dimension-repository_network_root_nwoNativeScript/ios
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/NativeScript/ios/issues/397#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fios%2Fissues%2F397
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fios%2Fissues%2F397
Sign uphttps://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=NativeScript%2Fios
Reloadhttps://github.com/NativeScript/ios/issues/397
Reloadhttps://github.com/NativeScript/ios/issues/397
Reloadhttps://github.com/NativeScript/ios/issues/397
NativeScripthttps://github.com/NativeScript
ioshttps://github.com/NativeScript/ios
Codehttps://github.com/NativeScript/ios
Issues56 (56)https://github.com/NativeScript/ios/issues
Pull requests42 (42)https://github.com/NativeScript/ios/pulls
Actionshttps://github.com/NativeScript/ios/actions
Projectshttps://github.com/NativeScript/ios/projects
Security and qualityhttps://github.com/NativeScript/ios/security
Insightshttps://github.com/NativeScript/ios/insights
https://github.com/NativeScript/ios
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/ios/issues/397
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/ios/issues/397
Worker teardown: AB-BA deadlock between main and worker V8 isolate locks (constrained-core/CI)https://github.com/NativeScript/ios/issues/397#top
https://github.com/NathanWalker
NathanWalkerhttps://github.com/NathanWalker
on Jun 27, 2026https://github.com/NativeScript/ios/issues/397#issue-4759117197
ClassBuilder.mm:262-296https://github.com/NativeScript/ios/blob/main/NativeScript/runtime/ClassBuilder.mm#L262
NathanWalkerhttps://github.com/NathanWalker
on Jun 27, 2026https://github.com/NativeScript/ios/issues/397#event-27283756338
test: quarantine TNS Workers teardown stress spec (CI deadlock, refs #…https://github.com/NativeScript/ios/commit/11a0e611c01d566ea10fe642dfe222915af40811
#…https://github.com/NativeScript/ios/issues/397
11a0e61https://github.com/NativeScript/ios/commit/11a0e611c01d566ea10fe642dfe222915af40811
test: quarantine TNS Workers teardown stress spec (CI deadlock, refs #…https://github.com/NativeScript/ios/commit/5dd6277d32d6d0e55e343b86c407e479f9a2beec
#…https://github.com/NativeScript/ios/issues/397
5dd6277https://github.com/NativeScript/ios/commit/5dd6277d32d6d0e55e343b86c407e479f9a2beec
test: quarantine TNS Workers teardown stress spec (CI deadlock, refs #…https://github.com/NativeScript/ios/commit/0c01ff2d0d544c4f1bdc5ee3d2db2ef0ad49468c
#…https://github.com/NativeScript/ios/issues/397
0c01ff2https://github.com/NativeScript/ios/commit/0c01ff2d0d544c4f1bdc5ee3d2db2ef0ad49468c
NathanWalkerhttps://github.com/NathanWalker
on Jul 23, 2026https://github.com/NativeScript/ios/issues/397#event-28400770266
test: quarantine TNS Workers teardown stress spec (CI deadlock, refs #…https://github.com/NativeScript/ios/commit/856f1b43ab0bbb3a22117b8642490effcba8bb3a
#…https://github.com/NativeScript/ios/issues/397
856f1b4https://github.com/NativeScript/ios/commit/856f1b43ab0bbb3a22117b8642490effcba8bb3a
test: unit test improvementshttps://github.com/NativeScript/ios/commit/64392d342d64ccf9d090df985c55838cfdb277ba
64392d3https://github.com/NativeScript/ios/commit/64392d342d64ccf9d090df985c55838cfdb277ba
test: unit test improvementshttps://github.com/NativeScript/ios/commit/c842d4662cc68d11b9bbcca4ea227887a8dffb85
c842d46https://github.com/NativeScript/ios/commit/c842d4662cc68d11b9bbcca4ea227887a8dffb85
test: unit test improvementshttps://github.com/NativeScript/ios/commit/c3c9dc68500e65efc2094332f8602952918635c8
c3c9dc6https://github.com/NativeScript/ios/commit/c3c9dc68500e65efc2094332f8602952918635c8
test: unit test improvementshttps://github.com/NativeScript/ios/commit/916cbbd8d876c81df75c628d209ed5d1b96c5772
916cbbdhttps://github.com/NativeScript/ios/commit/916cbbd8d876c81df75c628d209ed5d1b96c5772
test: unit test improvementshttps://github.com/NativeScript/ios/commit/06aad59fa3e2fbf4320f45f9f47614f148b5581a
06aad59https://github.com/NativeScript/ios/commit/06aad59fa3e2fbf4320f45f9f47614f148b5581a
https://github.com/edusperoni
edusperonihttps://github.com/edusperoni
on Aug 18, 2026https://github.com/NativeScript/ios/issues/397#issuecomment-5332458781
#428https://github.com/NativeScript/ios/pull/428
edusperonihttps://github.com/edusperoni
completedhttps://github.com/NativeScript/ios/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 18, 2026https://github.com/NativeScript/ios/issues/397#event-29638204380
Sign up for freehttps://github.com/signup?return_to=https://github.com/NativeScript/ios/issues/397
Sign in to commenthttps://github.com/login?return_to=https://github.com/NativeScript/ios/issues/397
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.