Skip to content

Deadlock when removing iframe from document. #11546

Closed

Description

@emilio

I think the fact that the iframe is not yet completely loaded might influence in the result, but not totally sure.

Testcase:

<!doctype html>
<title></title>
<script>
window.addEventListener('load', function() {
  var frame = null;
  setTimeout(function f() {
    if (frame)
      document.body.removeChild(frame);
    frame = document.createElement('iframe');
    frame.src = "data:text/html,<p>test</p><script>console.log('test')<" + "/script>";
    document.body.appendChild(frame);
    setTimeout(f, 1000);
  }, 1000);
}, false);
</script>
<div>test</div>

Activity

  1. added
    C-has-manual-testcase
    A-constellation
    on Jun 1, 2016
  2. emilio commented on Jun 1, 2016

    @emilio
    MemberAuthor

    Some backtraces of affected threads:

    Constellation

    Constellation is waiting on Pipeline::exit().

    (gdb) bt
    #0  0x00007ffff59db98d in recvmsg () at ../sysdeps/unix/syscall-template.S:84
    #1  0x0000555558a8ae62 in ipc_channel::platform::linux::{{impl}}::recv (self=0x7fffe89f6f98, fd=70, blocking_mode=Blocking)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/platform/linux/mod.rs:923
    #2  0x0000555558a7b7d5 in ipc_channel::platform::linux::recv (fd=70, blocking_mode=Blocking)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/platform/linux/mod.rs:761
    #3  0x0000555558a79840 in ipc_channel::platform::linux::{{impl}}::recv (self=0x7fffe89f7d38)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/platform/linux/mod.rs:86
    #4  0x0000555557c21a3f in ipc_channel::ipc::{{impl}}::recv<()> (self=0x7fffe89f7d38)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/ipc.rs:73
    #5  0x0000555557c214da in constellation::pipeline::{{impl}}::exit (self=0x7fffe89f7cd8) at /home/emilio/projects/moz/servo/components/constellation/pipeline.rs:326
    #6  0x0000555555b7a6cb in constellation::constellation::{{impl}}::close_pipeline<script::layout_interface::Msg,layout::layout_thread::LayoutThread,script::script_thread::ScriptThread>
        (self=0x7fffe89fc5e0, pipeline_id=..., exit_mode=Normal) at /home/emilio/projects/moz/servo/components/constellation/constellation.rs:1934
    #7  0x0000555555b7b865 in constellation::constellation::{{impl}}::close_frame<script::layout_interface::Msg,layout::layout_thread::LayoutThread,script::script_thread::ScriptThread> (
        self=0x7fffe89fc5e0, frame_id=..., exit_mode=Normal) at /home/emilio/projects/moz/servo/components/constellation/constellation.rs:1874
    #8  0x0000555555c988f6 in constellation::constellation::{{impl}}::handle_remove_iframe_msg<script::layout_interface::Msg,layout::layout_thread::LayoutThread,script::script_thread::ScriptThread> (self=0x7fffe89fc5e0, pipeline_id=...) at /home/emilio/projects/moz/servo/components/constellation/constellation.rs:1448
    #9  0x0000555555c860a5 in constellation::constellation::{{impl}}::handle_request_from_script<script::layout_interface::Msg,layout::layout_thread::LayoutThread,script::script_thread::ScriptThread> (self=0x7fffe89fc5e0, message=...) at /home/emilio/projects/moz/servo/components/constellation/constellation.rs:718
    #10 0x0000555555b00711 in constellation::constellation::{{impl}}::handle_request<script::layout_interface::Msg,layout::layout_thread::LayoutThread,script::script_thread::ScriptThread>
        (self=0x7fffe89fc5e0) at /home/emilio/projects/moz/servo/components/constellation/constellation.rs:526
    #11 0x0000555555afa986 in constellation::constellation::{{impl}}::run<script::layout_interface::Msg,layout::layout_thread::LayoutThread,script::script_thread::ScriptThread> (
        self=0x7fffe89fc5e0) at /home/emilio/projects/moz/servo/components/constellation/constellation.rs:390
    #12 0x0000555555ae1278 in _$LT$constellation..constellation..Constellation$LT$Message$C$$u20$LTF$C$$u20$STF$GT$$GT$::start::_$u7b$$u7b$closure$u7d$$u7d$::haaf81ac912498c19 ()
        at ../src/libstd/panicking.rs:232
    

    Iframe's ScriptThread

    It seems to be blocking in HTMLIFrameElement::unbind_from_tree(), waiting for the constellation.

    (gdb) bt
    #0  0x00007ffff59db98d in recvmsg () at ../sysdeps/unix/syscall-template.S:84
    #1  0x0000555558a8ae62 in ipc_channel::platform::linux::{{impl}}::recv (self=0x7fffe57f5d38, fd=69, blocking_mode=Blocking)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/platform/linux/mod.rs:923
    #2  0x0000555558a7b7d5 in ipc_channel::platform::linux::recv (fd=69, blocking_mode=Blocking)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/platform/linux/mod.rs:761
    #3  0x0000555558a79840 in ipc_channel::platform::linux::{{impl}}::recv (self=0x7fffe57f64a4)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/platform/linux/mod.rs:86
    #4  0x0000555556ea1d8f in ipc_channel::ipc::{{impl}}::recv<()> (self=0x7fffe57f64a4)
        at /home/emilio/projects/moz/servo/.cargo/git/checkouts/ipc-channel-8c79851162410a92/master/ipc.rs:73
    #5  0x0000555556ea15ca in script::dom::htmliframeelement::{{impl}}::unbind_from_tree (self=0x7fffeae27000, context=0x7fffe57f68e8)
        at /home/emilio/projects/moz/servo/components/script/dom/htmliframeelement.rs:581
    #6  0x0000555556f2a89d in script::dom::node::{{impl}}::remove_child (self=0x7fffe52e3600, child=0x7fffeae27000, cached_index=...)
        at /home/emilio/projects/moz/servo/components/script/dom/node.rs:288
    #7  0x0000555556f2f755 in script::dom::node::{{impl}}::remove (node=0x7fffeae27000, parent=0x7fffe52e3600, suppress_observers=Unsuppressed)
        at /home/emilio/projects/moz/servo/components/script/dom/node.rs:1627
    #8  0x0000555556f38243 in script::dom::node::{{impl}}::pre_remove (child=0x7fffeae27000, parent=0x7fffe52e3600) at /home/emilio/projects/moz/servo/components/script/dom/node.rs:1597
    #9  0x00005555569c4884 in script::dom::node::{{impl}}::RemoveChild (self=0x7fffe52e3600, node=0x7fffeae27000) at /home/emilio/projects/moz/servo/components/script/dom/node.rs:2131
    #10 0x00005555569c4577 in script::dom::bindings::codegen::Bindings::NodeBinding::removeChild (cx=0x7fffe52e0600, _obj=..., this=0x7fffe52e3600, args=0x7fffe57f6f40)
        at /home/emilio/projects/moz/servo/target/debug/build/script-5bfa5fd924db7653/out/Bindings/NodeBinding.rs:1237
    #11 0x00005555572d2f1c in CallJitMethodOp ()
    
  3. emilio commented on Jun 1, 2016

    @emilio
    MemberAuthor

    It seems in Pipeline::exit() the constellation is sending a ConstellationControlMsg to itself, then waiting to the effect of processing that message, which results in a deadlock, since it's already processing the first message.

  4. self-assigned this
    on Jun 1, 2016
  5. asajeffrey commented on Jun 1, 2016

    @asajeffrey
    Contributor

    The underlying problem is having the constellation block on anything other than the main event loop is a really bad idea, since it means a deadlocked pipeline can cause the whole constellation to deadlock.

  6. asajeffrey commented on Jun 1, 2016

    @asajeffrey
    Contributor

    OK, looking through the constellation code, the uses of recv in constellation.rs are:

    I think these are all OK, we certainly want to block on the main event loop and exit, it doesn't matter if reftests deadlock because that'll show up in testing, and there is a comment (https://github.com/servo/servo/blob/master/components/compositing/compositor.rs#L130) that the compositor never blocks on the constellation.

    Now to check pipeline.rs and compositor.rs...

  7. asajeffrey commented on Jun 1, 2016

    @asajeffrey
    Contributor
  8. asajeffrey commented on Jun 1, 2016

    @asajeffrey
    Contributor

    And in compositor.rs, the uses of recv are:

    These are both dangerous, but it looks like they can't cause deadlocks, that the "blocks-on" relationship is acyclic.

  9. asajeffrey commented on Jun 1, 2016

    @asajeffrey
    Contributor

    IRC chat: http://logs.glob.uno/?c=mozilla%23servo&s=1+Jun+2016&e=1+Jun+2016#c445562

    @larsbergstrom points out that synchronous shutdown is needed b/c "the graphics stack and spidermonkey behave really badly if they aren't the 'last' things to shutdown, as they're hiding a bunch of native resources."

  10. added 3 commits that reference this issue on Jun 3, 2016
    27d03d4
    d2bac9f
    6581e35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-constellationC-has-manual-testcase

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions