Repository navigation
Description
frame_converter.cc creates a new ObjectTemplate on every IPC call, causing V8 crash after days of runtime
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
40.10.2, 40.10.3
What operating system(s) are you using?
macOS
Operating System Version
macOS (Darwin 24.5.0), Mac mini (Macmini7,1)
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
The application should run stably for extended periods (days/weeks) without crashing, even with frequent synchronous IPC calls (e.g., from @electron/remote).
Actual Behavior
After 4–6 days of continuous runtime, the main process crashes with EXC_BREAKPOINT (SIGTRAP) inside V8's InstantiateFunction() when processing a synchronous IPC message. The crash occurs consistently after an idle period (~45 minutes), suggesting it is triggered by V8's idle-time Major GC (Mark-Compact with compaction).
Three independent crash reports from different app versions (40.10.2 and 40.10.3) all show the same crash path.
Testcase Gist URL
No response
Additional Information
Root Cause Analysis
The crash originates in shell/common/gin_converters/frame_converter.cc, where Converter<gin_helper::AccessorValue<content::RenderFrameHost*>>::ToV8() creates a new v8::ObjectTemplate on every call:
v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
templ->SetInternalFieldCount(2);
v8::Local<v8::Object> rfh_obj =
templ->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();This code runs on every synchronous IPC call via the following path:
ipcRenderer.sendSync()
→ ElectronApiIPCHandlerImpl::MessageSync() // electron_api_ipc_handler_impl.cc:103
→ MakeIPCEvent() // electron_api_ipc_handler_impl.cc:179
→ dict.SetGetter("senderFrame", frame)
→ Converter<AccessorValue<RFH*>>::ToV8() // frame_converter.cc:49
→ ObjectTemplate::New(isolate) // NEW template every time
→ templ->NewInstance(context)
→ V8 InstantiateFunction() // CRASH here
v8::ObjectTemplate and its implicit FunctionTemplateInfo constructor are designed to be created once and reused. Creating and discarding them on every IPC call is an unusual pattern that stresses a rarely-tested V8 code path. Over millions of IPC calls (especially from @electron/remote which uses sendSync extensively), this accumulates a large number of short-lived template objects in V8's old generation heap.
When the app goes idle, V8's idle-time GC performs a Major GC (Mark-Compact with compaction), and during this process, a FunctionTemplateInfo object's bit fields become corrupted. The next IPC call after the idle period then crashes when InstantiateFunction() reads the invalid bit field.
Fully Symbolicated Crash Stack (from Breakpad minidump + symbols)
Frame 0: InstantiateFunction(Isolate*, NativeContext, FunctionTemplateInfo, Name) [bit-field.h:80]
Frame 1: InstantiateObject(Isolate*, ObjectTemplateInfo, JSReceiver, bool) [api-natives.cc:54]
Frame 2: ApiNatives::InstantiateObject(...) [api-natives.cc:514]
Frame 3: v8::ObjectTemplate::NewInstance(context) [api.cc:7227]
Frame 4: gin::Converter<AccessorValue<RenderFrameHost*>>::ToV8() [frame_converter.cc:60]
Frame 5: Dictionary::SetGetter<"senderFrame", RenderFrameHost*>() [converter.h:327]
Frame 6: ElectronApiIPCHandlerImpl::MakeIPCEvent() [electron_api_ipc_handler_impl.cc:179]
Frame 7: ElectronApiIPCHandlerImpl::MessageSync() [electron_api_ipc_handler_impl.cc:103]
Frame 8: ElectronApiIPCStubDispatch::AcceptWithResponder() [api.mojom.cc:2362]
...
Frame 17: ThreadControllerWithMessagePumpImpl::DoWork() [task_annotator.h:113]
→ CoreFoundation CFRunLoop → AppKit → ElectronMain
Proposed Fix
Cache the ObjectTemplate using v8::Eternal so it is created only once per isolate:
static v8::Eternal<v8::ObjectTemplate> cached_templ;
if (cached_templ.IsEmpty()) {
v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
templ->SetInternalFieldCount(2);
cached_templ.Set(isolate, templ);
}
v8::Local<v8::ObjectTemplate> templ = cached_templ.Get(isolate);
v8::Local<v8::Object> rfh_obj =
templ->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();This is consistent with how other parts of Electron handle ObjectTemplate creation (e.g., via gin::ObjectTemplateBuilder which caches templates).
Observations from crash reports
| Report | Electron | Uptime before crash | Idle before crash |
|---|---|---|---|
| 1 (2026-07-06) | 40.10.2 | ~4 days | unknown |
| 2 (2026-07-12) | 40.10.3 | ~6 days | ~45 min |
| 3 (2026-07-13) | 40.10.3 | ~5.5 days | ~45 min |
- All crashes on same hardware (Macmini7,1, x64, 16GB RAM)
- All show identical crash signature:
EXC_BREAKPOINTinInstantiateFunctionviaframe_converter.cc - The code in
main,41-x-y,42-x-y, and43-x-ybranches is identical — this issue affects all current Electron versions
Activity
nikwen commentedon Jul 14, 2026
Thanks for reporting!
@electron/remotemodule? I'd like to isolate if this issue is a result of a bug in that module or in Electron itself. It's not recommended to use@electron/remote.@electron/remotemodule, could you please download Electron Fiddle, use it to create a small sample app that allows maintainers to reproduce this issue, and upload it as a GitHub gist from Fiddle? Also, please share an updated stacktrace in that case.electron-issue-triage commentedon Jul 14, 2026
Hello @yungchao. Thanks for reporting this and helping to make Electron better!
Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.
Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.
Now adding the blocked/need-reproNeeds a test case to reproduce the bug
label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.
fix: cache ObjectTemplate in frame_converter.cc to prevent V8 crash
fix: cache ObjectTemplate in frame_converter.cc to prevent V8 crash
yungchao commentedon Jul 15, 2026
Atttach crash report on mac computers.
Archive.zip
yungchao commentedon Jul 16, 2026
Attach minidump .dmp files
minidump.zip
yungchao commentedon Jul 16, 2026
Seems not only sendSync, but all IPC calls from renderer to main will encounter the same issue:
Message,Invoke,ReceivePostMessage,MessageSync) callsMakeIPCEvent, which doesdict.SetGetter("senderFrame", frame)(shell/browser/electron_api_ipc_handler_impl.cc).
v8::ObjectTemplateon every call —there is no caching (shell/common/gin_converters/frame_converter.cc:~60):
SetGetteradditionally creates a getterFunctionTemplate. Net cost:~2–3 V8 template serial numbers per IPC message, allocated from a
monotonically increasing, never-recycled per-isolate counter
(
Heap::GetNextTemplateSerialNumber).(
TemplateInfo::SerialNumberBits) whoseencode()is guarded by arelease-mode
CHECK. V8's own overflow guard wraps atSmi::kMaxValue(2^31), which is unreachable — the CHECK fires first at 2^29.
My previous statement about GC might be wrong, serial number overflow looks more like the root cause.
nikwen commentedon Jul 16, 2026
Could you please reply to the questions from my previous message?
yungchao commentedon Jul 18, 2026
Hi Nikwen,
I've attached an electron_ipc_crash poc project which use electron v43.1.1 to reproduce this issue, also includes a Mac crash report:
The crash is reproduced by @electron/remote IPC method because it can create lots more IPC stress, it took ~13 hours to reproduce, if choose sendSync IPC mothod it should take much longer time. And the reason I choosed to a poc project instead of using Fiddle is because which can simuate the reported real case.
pocproject_and_crashreport.zip
yungchao commentedon Jul 26, 2026
Hi Nikwen,
A similar issue found on Windows Server 2022, you may refer to the zipped the minidump file.
cc1c850c-d20f-4986-8237-05340d737196.dmp.zip
electron-issue-triage commentedon Aug 28, 2026
Unfortunately, without a way to reproduce this issue, we're unable to continue investigation. This issue has been closed and will not be monitored further. If you're able to provide a minimal test case that reproduces this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.