Infinite Loop in StackHandlerIterator::Advance() Due to Cyclic Handler

15 views
Skip to first unread message

Yash Jain

unread,
Apr 17, 2025, 8:45:29 AM4/17/25
to v8-...@googlegroups.com

Hi,

I'm Yash, currently working on the PostgreSQL plv8 extension, which integrates the V8 JavaScript engine. During one of the regression tests [1], the following query results in an error and causes the process to hang indefinitely:

SELECT caller(10, 3); 
ERROR:  javascript function is not found for "sqlf"
CONTEXT:  caller() LINE 8:     func = plv8.find_function("sqlf");

While debugging the V8 engine, I made the following observations:

  1. In VisitStack() (isolate.cc), the following loop hangs:

    for (StackFrameIterator it(isolate); !it.done(); it.Advance()) {
    
  2. Diving deeper, inside StackFrameIterator::Advance() (frames.cc [2]), the loop:

    while (!it.done()) { it.Advance(); }
    

    gets stuck because of this line:

    handler_ = handler_->next();
    

    It appears that handler_->next() is pointing back to handler_ itself, creating a cycle and causing an infinite loop.

Could someone help me understand why handler_->next() could end up pointing to itself, instead of being nullptr? I'm trying to trace the root cause of this corrupted/cyclic stack handler state.

Any guidance on how to further debug this would be appreciated.

References:- 

[1] https://github.com/plv8/plv8/blob/r3.2/sql/plv8.sql#L403

[2] https://github.com/v8/v8/blob/main/src/execution/frames.cc#L119

Reply all
Reply to author
Forward
0 new messages