Issue 14364 in v8: StackTrace::CurrentStackTrace doesn't do async stack traces

8 views
Skip to first unread message

ilya.… via monorail

unread,
Oct 5, 2023, 5:43:33 PM10/5/23
to v8-re...@googlegroups.com
Status: Untriaged
Owner: ----
Type: Bug

New issue 14364 by ilya....@gmail.com: StackTrace::CurrentStackTrace doesn't do async stack traces
https://bugs.chromium.org/p/v8/issues/detail?id=14364

Stack traces captured with `StackTrace::CurrentStackTrace` don't cross the event loop "boundary" unlike stacks captured when constructing an `Error`.

This relates to using v8 with node, which does async stack traces, and was opened as https://github.com/nodejs/node/issues/50056 initially. (I'm not sure whether "async stack traces" are more of a v8 concern or a node concern.)

**Use case**

I'm using fast-blocked-at, a library which starts a watchdog thread and whenever it appears that the event loop is blocked, it interrupts the isolate[^1] to run `StackTrace::CurrentStackTrace` on it[^2].

Example use:
```js
import blockedAt from "fast-blocked-at";
const yield = () => new Promise((r) => setTimeout(r, 0));

blockedAt((durationMs, stack) => {
console.log(`detected block for ${durationMs}ms`)
console.log(stack)
console.log('---')
}, {
threshold: 100,
interval: 50,
});

async function busySleep(blockMs) {
const start = Date.now();
while (Date.now() - start < blockMs); // blocking loop!
}

async function test() {
await busySleep(1000); // stack trace will be full
await yield();
await busySleep(1000); // stack trace will the chopped at 'test'
}

(async () => {
await test();
await yield(); // allow the heartbeat invoke the callback.
})();
```

This results in:
```
detected block for 975ms
at busySleep (fast-blocked-at/test/await_stack.js:6:5)
at test (fast-blocked-at/test/await_stack.js:10:11)
at main (fast-blocked-at/test/await_stack.js:25:11)
at (unknown) (fast-blocked-at/test/await_stack.js:27:3)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at executeUserEntryPoint (node:internal/modules/run_main:86:12)
at (unknown) (node:internal/main/run_main_module:23:47)
---
detected block for 979ms
at busySleep (fast-blocked-at/test/await_stack.js:6:5)
at test (fast-blocked-at/test/await_stack.js:12:11)
---
```

[^1]: https://git.sr.ht/~kvakil/fast-blocked-at/tree/master/item/native.cc#L124
[^2]: https://git.sr.ht/~kvakil/fast-blocked-at/tree/master/item/native.cc#L246

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

ecmzi… via monorail

unread,
Oct 17, 2023, 9:32:39 AM10/17/23
to v8-re...@googlegroups.com
Updates:
Cc: cbr...@chromium.org
Components: Runtime
Labels: Priority-2

Comment #1 on issue 14364 by ecmzi...@chromium.org: StackTrace::CurrentStackTrace doesn't do async stack traces
https://bugs.chromium.org/p/v8/issues/detail?id=14364#c1

(No comment was entered for this change.)

ecmzi… via monorail

unread,
Oct 19, 2023, 4:49:33 AM10/19/23
to v8-re...@googlegroups.com
Updates:
Status: Available

Comment #2 on issue 14364 by ecmzi...@chromium.org: StackTrace::CurrentStackTrace doesn't do async stack traces
https://bugs.chromium.org/p/v8/issues/detail?id=14364#c2
Reply all
Reply to author
Forward
0 new messages