Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: DevTools performance profile lead to crash (or Renderer crash) on Apple M1 MacOS BigSur 11.3.1 #29627

Closed
3 tasks done
nbashkankov opened this issue Jun 10, 2021 · 25 comments

Comments

@nbashkankov
Copy link

Preflight Checklist

Electron Version

7.2.1, 11.4.2

What operating system are you using?

macOS

Operating System Version

11.3.1

What arch are you using?

x64

Last Known Working Electron version

N/a

Expected Behavior

Open DevTools-> Performance tab -> press "Capture"

Tracing starts capturing without crasing Renderer or Full Application.

Actual Behavior

There are different behavior on various electron version:
Electron 7.2.1 - Only Renderer process gone with WSOD - issue is floating - sometimes renderer crash/sometimes not (cant find pattern)
[ERROR:platform_shared_memory_region_mac.cc(230)] mach_vm_map: (ipc/send) invalid msg-header (0x10000010)
after that error Renderer on which Capture was started are crashed, rest of Application (Main and other processes works ok)

Electron 11.4.2 - Right after Capture press - whole App freezing - and later App crash with MacOS report:
sometimes i see this error:

[ERROR:platform_shared_memory_region_mac.cc(205)] mach_vm_map: (ipc/send) invalid msg-header (0x10000010)

System Integrity Protection: enabled

Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000002, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Trace/BPT trap: 5
Termination Reason:    Namespace SIGNAL, Code 0x5
Terminating Process:   exc handler [13703]

Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   com.github.Electron.framework 	0x000000010bcc4af9 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 6234585
1   libsystem_kernel.dylib        	0x00007fff203c5e0a __sigreturn + 10

Thread 1:: com.apple.rosetta.exceptionserver
0   runtime                       	0x00007ffdffbde878 0x7ffdffbdd000 + 6264
1   runtime                       	0x00007ffdffbe8d70 0x7ffdffbdd000 + 48496
2   runtime                       	0x00007ffdffbe9a40 0x7ffdffbdd000 + 51776

Thread 2:
0   runtime                       	0x00007ffdffc3799c 0x7ffdffbdd000 + 371100

sometimes this:

assertion failed: emulated forward to an arm pc that isn't in translated code.  arm_pc=0x118862064 abi_kind=4 emulation_interval=[0x11a13fbbc,0x11abcf88c) instruction_interval=[0x11abcf864, 0x11abcf88c) x86_rip=0x10f05c70a
(ThreadContextRegisterState.cpp:690 move_to_instruction_boundary)

Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       EXC_ARM_BREAKPOINT at 0x00007ffdffee2360 (brk 1)
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Trace/BPT trap: 5
Termination Reason:    Namespace SIGNAL, Code 0x5
Terminating Process:   exc handler [13498]

Application Specific Information:
assertion failed: emulated forward to an arm pc that isn't in translated code.  arm_pc=0x118862064 abi_kind=4 emulation_interval=[0x11a13fbbc,0x11abcf88c) instruction_interval=[0x11abcf864, 0x11abcf88c) x86_rip=0x10f05c70a
(ThreadContextRegisterState.cpp:690 move_to_instruction_boundary)
 

Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   runtime                       	0x00007ffdffee2360 0x7ffdffe8f000 + 340832
1   runtime                       	0x00007ffdffee1d6c 0x7ffdffe8f000 + 339308
2   runtime                       	0x00007ffdffea4a58 0x7ffdffe8f000 + 88664
3   runtime                       	0x00007ffdffea7138 0x7ffdffe8f000 + 98616
4   runtime                       	0x00007ffdffee9808 0x7ffdffe8f000 + 370696
5   <translation info unavailable>	0x00000001011291f0 ???
6   com.github.Electron.framework 	0x000000010993707e v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7198558
7   com.github.Electron.framework 	0x000000010ccfa3c5 v8::internal::compiler::ZoneStats::GetCurrentAllocatedBytes() const + 13320485
8   com.github.Electron.framework 	0x000000010ccfa526 v8::internal::compiler::ZoneStats::GetCurrentAllocatedBytes() const + 13320838
9   com.github.Electron.framework 	0x000000010c2c5475 v8::internal::compiler::ZoneStats::GetCurrentAllocatedBytes() const + 2617813
10  com.github.Electron.framework 	0x00000001094d324e v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 2595118
11  com.github.Electron.framework 	0x00000001094bf8f1 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 2514897
12  com.github.Electron.framework 	0x000000010894bc74 ElectronInitializeICUandStartNode + 2509044

both cases for Electrons 11 has in common issue after SetupIsolateDelegate::SetupHeap(v8::internal::Heap*)

Testcase Gist URL

No response

Additional Information

No response

@nbashkankov nbashkankov changed the title [Bug]: DevTools performance profile lead to crash (render crash) on Apple M1 MacOS BigSur 11.3.1 [Bug]: DevTools performance profile lead to crash (or Renderer crash) on Apple M1 MacOS BigSur 11.3.1 Jun 10, 2021
@zcbenz
Copy link
Contributor

zcbenz commented Jun 15, 2021

Does this problem happen on later versions >= 12?

@nornagon
Copy link
Member

Please attach a crash dump. You can collect them by adding the following snippet to your main process code, before app.whenReady:

const { app, crashReporter } = require('electron')

console.log(app.getPath('crashDumps'))
crashReporter.start({ submitURL: '', uploadToServer: false })

Then reproduce the crash, zip up the crash dumps directory and attach it here.

@nbashkankov
Copy link
Author

Does this problem happen on later versions >= 12?

checked on Electron 12.0.9
Same result: right after record started - freeze than crash with same reason about SetupHeap

Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000002, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Trace/BPT trap: 5
Termination Reason:    Namespace SIGNAL, Code 0x5
Terminating Process:   exc handler [21902]

Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   com.github.Electron.framework 	0x000000010a414fc9 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 6271689
1   libsystem_kernel.dylib        	0x00007fff20429e0a __sigreturn + 10
2   ???                           	0x00007f84db9533e8 ???
3   com.github.Electron.framework 	0x000000010a5639f7 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7642359
4   com.github.Electron.framework 	0x000000010a563d8e v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7643278
5   com.github.Electron.framework 	0x000000010a56cfff v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7680767
6   com.github.Electron.framework 	0x000000010cf9e088 v8::internal::compiler::ZoneStats::GetCurrentAllocatedBytes() const + 6977144
7   com.github.Electron.framework 	0x000000010a550b0a v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7564810
8   com.github.Electron.framework 	0x000000010a556366 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7587430
9   com.github.Electron.framework 	0x000000010a555cdd v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7585757
10  com.github.Electron.framework 	0x000000010a54e4e0 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7555040
11  com.github.Electron.framework 	0x000000010a54ed9e v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 7557278

from electron logs (--enable-logging v1):

[:ERROR:platform_shared_memory_region_mac.cc(205)] mach_vm_map: (ipc/send) invalid msg-header (0x10000010)

@nornagon
Copy link
Member

SetupHeap is a mislabeling of the address. Please attach a crash dump, using the instructions in #29627 (comment)

@nbashkankov
Copy link
Author

nbashkankov commented Jun 17, 2021

SetupHeap is a mislabeling of the address. Please attach a crash dump, using the instructions in #29627 (comment)

hi - tryed with 11.4.1 - unfortunately - no luck with crashpad - chrome_crashpad_handler didnt capture any crash dump.
crashDumps folder are always empty - even if i just manually call process.crash()
(only .../Crashpad/settings.dat file always changed but it has 40 bytes size)

i see that chrome_crashpad_handler launched right after App started and closed after crash, but no dumps 🤷‍♂️

@nornagon
Copy link
Member

Hm, that's worrisome! Can you try out this super simple repo just to make sure we're testing the same thing? https://gist.github.com/nornagon/d3d4f440a83eca642b076f28a12d8d10

Instructions:

git clone https://gist.github.com/d3d4f440a83eca642b076f28a12d8d10.git crash-test
cd crash-test
npm install
npm start
ls ~/Library/Application\ Support/crash-test/Crashpad/pending

It should list a .dmp file.

@nbashkankov
Copy link
Author

@nornagon - followed your instruction - no luck:
image

image

@nornagon
Copy link
Member

nothing in completed or new either?

@blaadje
Copy link

blaadje commented Jun 19, 2021

Hi, got the same issue Mac m1 os 11.1 , Electron 13.1.2.
Tried the Crashpad as well and nothing in there

image

The issue happens 100% of time.

@nbashkankov
Copy link
Author

nbashkankov commented Jun 21, 2021

nothing in completed or new either?

yep. all folders are empty. Probably there is separate issue with Crashpad on M1 - but it outside of my topic

issue from topic is really important - it blocks me from investigating performance issues.

Even more - i tryed to capture trace via CDP(ChromeDevToolsProtocol) client - same issue -
App crashed when Tracing.start executed

@nornagon
Copy link
Member

@blaadje / @nbashkankov can you confirm that you're using the arm64 version of Electron on the M1 and not the x64 version under emulation?

@nbashkankov
Copy link
Author

Nope - i use only x64 version under emulation
Electron versions: 7.2.1 (afaik there is impossible to get arm version), 11.4.1, 12.0.9 - all was x64 -
and i expect DevTools fully works for x64 version even under emulation

@nornagon
Copy link
Member

Do you have the same issue when using the arm64 version? It's useful to know that this is specific to the emulated version!

@nbashkankov
Copy link
Author

nbashkankov commented Jun 22, 2021

i checked Tracing capture with Chrome Version 91.0.4472.106 (Official Build) (arm64) - works ok - without crashing.

@nornagon can you please guide what the shortest way for getting arm build of Electron?

@nornagon
Copy link
Member

@nbashkankov all Electron releases since 11.x have arm64 versions. npm install electron ought to be giving you the arm64 version.

@nbashkankov
Copy link
Author

nbashkankov commented Jun 29, 2021

Hello @nornagon
Sorry for delay.

@nbashkankov all Electron releases since 11.x have arm64 versions. npm install electron ought to be giving you the arm64 version.

Looks like its not true:
Here steps to reproduce: i tried for 11.4.2
package.json

{
  "name": "crash-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "electron ."
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "electron": "11.4.2"
  }
}

index.js:

const { app, BrowserWindow } = require("electron");

let win;
app.whenReady().then(() => {
  win = new BrowserWindow({ width: 800, height: 600 });
  win.loadURL("https://www.youtube.com").then(() => {
    try {
      win.webContents.debugger.attach("1.3");
      console.log("Debugger attached");
    } catch (err) {
      console.log("Debugger attach failed : ", err);
    }

    win.webContents.debugger.on("detach", (event, reason) => {
      console.log("Debugger detached due to : ", reason);
    });

    const tracedEvents = [];
    win.webContents.debugger.on("message", (event, method, params) => {
      // console.log("Debugger event", event, method, params);
      if (method === "Tracing.dataCollected") {
        tracedEvents.push(event);
      }
      if (method === "Tracing.tracingComplete") {
        console.log("trace collected", tracedEvents.length);
        win.webContents.debugger.detach();
        setTimeout(() => app.quit(), 100);
      }
    });

    const TRACE_CATEGORIES = [
      "-*",
      "devtools.timeline",
      "toplevel",
      "blink.console",
      "blink.user_timing",
      "cpu_profiler",
      "disabled-by-default-devtools.timeline",
      "disabled-by-default-devtools.timeline.frame",
      "disabled-by-default-devtools.timeline.stack",
      "disabled-by-default-devtools.screenshot",
      "disabled-by-default-v8.cpu_profile",
      "disabled-by-default-v8.cpu_profiler",
    ];
    win.webContents.debugger.sendCommand("Tracing.start", {
      traceConfig: {
        includedCategories: TRACE_CATEGORIES,
      },
    });

    setTimeout(
      () => win.webContents.debugger.sendCommand("Tracing.end"),
      30000
    );
  });
});

first of all its not ARM!!!:
image

second: it crashed (if not you can try to scroll for a while and it will!!
here output:

•100% ➜ npm run start

> crash-test@1.0.0 start /Users/xxx/Projects/crash-test
> electron .

(node:36023) electron: The default of contextIsolation is deprecated and will be changing from false to true in a future release of Electron.  See https://github.com/electron/electron/issues/23506 for more information
Debugger attached
assertion failed: emulated forward to an arm pc that isn't in translated code.  arm_pc=0x11c768064 abi_kind=4 emulation_interval=[0x11cdada10,0x11eaca52c) instruction_interval=[0x11eaca504, 0x11eaca52c) x86_rip=0x113102b98
(ThreadContextRegisterState.cpp:690 move_to_instruction_boundary)
Debugger event {
  preventDefault: [Function: preventDefault],
  sender: Debugger {
    attach: [Function: attach],
    isAttached: [Function: isAttached],
    detach: [Function: detach],
    sendCommand: [Function: sendCommand],
    _events: [Object: null prototype] {
      detach: [Function],
      message: [Function],
      'Tracing.dataCollected': [Function]
    },
    _eventsCount: 3
  }
} **Inspector.targetCrashed** {}
[36023:0629/161501.011156:FATAL:platform_shared_memory_region_mac.cc(181)] Check failed: kr == KERN_SUCCESS. **mach_make_memory_entry_64: (ipc/send) invalid msg-header (0x10000010)**
/Users/xxx/Projects/crash-test/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGTRAP

so again issue with invalid msg-header

Same for Electron 12.0.12: and its not ARM again!!!
Renderer just crashed during scroll:

// update electron in package.json to 12.0.12
•100% ➜ npm install

> electron@12.0.12 postinstall /Users/xxx/Projects/crash-test/node_modules/electron
> node install.js

npm WARN crash-test@1.0.0 No description
npm WARN crash-test@1.0.0 No repository field.

updated 2 packages and audited 87 packages in 41.113s
found 0 vulnerabilities


~/Projects/crash-test on  master [!?] is 📦  v1.0.0 via ⬢ v12.22.1 took 42s 
•100% ➜ npm run start

> crash-test@1.0.0 start /Users/xxx/Projects/crash-test
> electron .

Debugger attached
Debugger event {
  preventDefault: [Function: preventDefault],
  sender: Debugger {
    attach: [Function: attach],
    isAttached: [Function: isAttached],
    detach: [Function: detach],
    sendCommand: [Function: sendCommand],
    _events: [Object: null prototype] {
      detach: [Function (anonymous)],
      message: [Function (anonymous)],
      'Tracing.dataCollected': [Function (anonymous)]
    },
    _eventsCount: 3
  }
} **Inspector.targetCrashed** {}
^C/Users/xxx/Projects/crash-test/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGINT

@nornagon
Copy link
Member

Hm, weird. @MarshallOfSound do you have any thoughts as to why npm install here is providing the x64 build here instead of the arm64 build?

@MarshallOfSound
Copy link
Member

If you're using an x64 version of node it will download an x64 version of Electron.

Run node -p "process.arch" and check the output. Also file $(which node) will tell you.

You can force the arm64 download with npm_config_arch=arm64 npm install

@nbashkankov
Copy link
Author

nbashkankov commented Jun 30, 2021

@MarshallOfSound - yep you right - i am using Node 12.22.1 - its x64 (afaik official arm build is v16).

with npm_config_arch=arm64 npm install - i got ARM version of Electron (11.4.2) -
I think its should be added somewhere to manuals.

Tried my snippet with tracing - and all works without any crash and trace events are successfully collected after 30 seconds.

But, when i did recording manually with just webContents.openDevTools() (and do scroll for about 10-30 second) - Renderer just frozen - when i press "Stop" DevTools just hangs out on - i double checked - its ARM version
image

@nornagon repeated it twice in a row - looks like there something more than just issue with emulation.

@nbashkankov
Copy link
Author

@nornagon @MarshallOfSound - any news here about why Tracing capture leads to crash?

@LeoEatle
Copy link

Any progress?

@nornagon
Copy link
Member

Is there a crash happening, or is the renderer frozen? If the latter, please collect a sample of the frozen process and attach the complete output here.

@gfomenkoevinced
Copy link

Any progress? :)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Nov 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants