| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 250e197 commit 337ebfc
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -166,25 +166,15 @@ inline void AsyncHooks::push_async_context(double async_id, | |||
| 166 | 166 | inline bool AsyncHooks::pop_async_context(double async_id) { | |
| 167 | 167 | // In case of an exception then this may have already been reset, if the | |
| 168 | 168 | // stack was multiple MakeCallback()'s deep. | |
| 169 | - if (fields_[kStackLength] == 0) return false; | ||
| 169 | + if (UNLIKELY(fields_[kStackLength] == 0)) return false; | ||
| 170 | 170 | ||
| 171 | 171 | // Ask for the async_id to be restored as a check that the stack | |
| 172 | 172 | // hasn't been corrupted. | |
| 173 | 173 | // Since async_hooks is experimental, do only perform the check | |
| 174 | 174 | // when async_hooks is enabled. | |
| 175 | - if (fields_[kCheck] > 0 && async_id_fields_[kExecutionAsyncId] != async_id) { | ||
| 176 | - fprintf(stderr, | ||
| 177 | - "Error: async hook stack has become corrupted (" | ||
| 178 | - "actual: %.f, expected: %.f)\n", | ||
| 179 | - async_id_fields_.GetValue(kExecutionAsyncId), | ||
| 180 | - async_id); | ||
| 181 | - DumpBacktrace(stderr); | ||
| 182 | - fflush(stderr); | ||
| 183 | - if (!env()->abort_on_uncaught_exception()) | ||
| 184 | - exit(1); | ||
| 185 | - fprintf(stderr, "\n"); | ||
| 186 | - fflush(stderr); | ||
| 187 | - ABORT_NO_BACKTRACE(); | ||
| 175 | + if (UNLIKELY(fields_[kCheck] > 0 && | ||
| 176 | + async_id_fields_[kExecutionAsyncId] != async_id)) { | ||
| 177 | + FailWithCorruptedAsyncStack(async_id); | ||
| 188 | 178 | } | |
| 189 | 179 | ||
| 190 | 180 | uint32_t offset = fields_[kStackLength] - 1; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1196,6 +1196,21 @@ void AsyncHooks::grow_async_ids_stack() { | |||
| 1196 | 1196 | async_ids_stack_.GetJSArray()).Check(); | |
| 1197 | 1197 | } | |
| 1198 | 1198 | ||
| 1199 | + void AsyncHooks::FailWithCorruptedAsyncStack(double expected_async_id) { | ||
| 1200 | + fprintf(stderr, | ||
| 1201 | + "Error: async hook stack has become corrupted (" | ||
| 1202 | + "actual: %.f, expected: %.f)\n", | ||
| 1203 | + async_id_fields_.GetValue(kExecutionAsyncId), | ||
| 1204 | + expected_async_id); | ||
| 1205 | + DumpBacktrace(stderr); | ||
| 1206 | + fflush(stderr); | ||
| 1207 | + if (!env()->abort_on_uncaught_exception()) | ||
| 1208 | + exit(1); | ||
| 1209 | + fprintf(stderr, "\n"); | ||
| 1210 | + fflush(stderr); | ||
| 1211 | + ABORT_NO_BACKTRACE(); | ||
| 1212 | + } | ||
| 1213 | + | ||
| 1199 | 1214 | void Environment::Exit(int exit_code) { | |
| 1200 | 1215 | if (options()->trace_exit) { | |
| 1201 | 1216 | HandleScope handle_scope(isolate()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -774,6 +774,8 @@ class AsyncHooks : public MemoryRetainer { | |||
| 774 | 774 | friend class Environment; // So we can call the constructor. | |
| 775 | 775 | explicit AsyncHooks(v8::Isolate* isolate, const SerializeInfo* info); | |
| 776 | 776 | ||
| 777 | + [[noreturn]] void FailWithCorruptedAsyncStack(double expected_async_id); | ||
| 778 | + | ||
| 777 | 779 | // Stores the ids of the current execution context stack. | |
| 778 | 780 | AliasedFloat64Array async_ids_stack_; | |
| 779 | 781 | // Attached to a Uint32Array that tracks the number of active hooks for | |
| Back | FazBrowse Home | New Git URL |
0 commit comments