https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89893

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
So I was able to track that to a single function:

diff --git a/src/node_platform.cc b/src/node_platform.cc
index fd8d045..ba344ba 100644
--- a/src/node_platform.cc
+++ b/src/node_platform.cc
@@ -346,6 +346,7 @@ void
PerIsolatePlatformData::DeleteFromScheduledTasks(DelayedTask* task) {

 void PerIsolatePlatformData::RunForegroundTask(uv_timer_t* handle) {
   DelayedTask* delayed = static_cast<DelayedTask*>(handle->data);
+  __builtin_printf ("run fore %p\n", delayed);
   RunForegroundTask(std::move(delayed->task));
   delayed->platform_data->DeleteFromScheduledTasks(delayed);
 }
@@ -366,11 +367,13 @@ void NodePlatform::DrainBackgroundTasks(Isolate* isolate)
{
   } while (per_isolate->FlushForegroundTasksInternal());
 }

+#pragma GCC optimize ("O2")
 bool PerIsolatePlatformData::FlushForegroundTasksInternal() {
   bool did_work = false;

   while (std::unique_ptr<DelayedTask> delayed =
       foreground_delayed_tasks_.Pop()) {
+    __builtin_printf ("foreground_delayed_tasks_ called: %p\n",
delayed.get());
     did_work = true;
     uint64_t delay_millis =
         static_cast<uint64_t>(delayed->timeout + 0.5) * 1000;
@@ -385,16 +388,20 @@ bool
PerIsolatePlatformData::FlushForegroundTasksInternal() {
                                           [](DelayedTask* delayed) {
       uv_close(reinterpret_cast<uv_handle_t*>(&delayed->timer),
                [](uv_handle_t* handle) {
-        delete static_cast<DelayedTask*>(handle->data);
+        DelayedTask *dt = static_cast<DelayedTask*>(handle->data);
+        __builtin_printf ("deleting %p\n", dt);
+        delete dt;
       });
     });
   }
+
   // Move all foreground tasks into a separate queue and flush that queue.
   // This way tasks that are posted while flushing the queue will be run on
the
   // next call of FlushForegroundTasksInternal.
   std::queue<std::unique_ptr<Task>> tasks = foreground_tasks_.PopAll();
   while (!tasks.empty()) {
     std::unique_ptr<Task> task = std::move(tasks.front());
+    __builtin_printf ("foreground_tasks_ called: %p\n", task.get());
     tasks.pop();
     did_work = true;
     RunForegroundTask(std::move(task));

Using that version I see:
...
RegExp              : 7291
----
Score (version 9): 7291
 duration  0  seconds
(node:19073) [DEP0016] DeprecationWarning: 'GLOBAL' is deprecated, use 'global'
foreground_delayed_tasks_ called: 0x1de23b0
foreground_tasks_ called: 0x1dd6ee8
foreground_tasks_ called: 0x1da3d88

while commenting out the '#pragma GCC optimize ("O2")' line one can see:
...
foreground_delayed_tasks_ called: 0x1d7e900
foreground_tasks_ called: 0x1ddc268
foreground_tasks_ called: 0x1dc53c8
run fore 0x1d7e900
run fore 0x1d7e900

So void PerIsolatePlatformData::RunForegroundTask(uv_timer_t* handle) is called
and delayed->task == NULL.
I'm not much familiar with unique_ptr, but first loop in
FlushForegroundTasksInternal calls
delayed.release() and there's quite a lot of casting as well.
Can you 康 珊 investigate that?

Reply via email to