servo: Assertion failure: maybeCCWRealm() == shape->realm() on discord.com/login

Unfortunately this happens very rarely. I tried reproducing it around 30 times but only got the crash twice.

misaligned pointer dereference: address must be a multiple of 0x8 but is 0x4b4b4b4b4b4b4b4b (thread Script(1,1), at /home/alaska/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/8ac1958/mozjs/src/rust.rs:846)
   0: servoshell::backtrace::print
   1: servoshell::panic_hook::panic_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic_handler::{{closure}}
   4: std::sys::backtrace::__rust_end_short_backtrace
   5: rust_begin_unwind
   6: core::panicking::panic_nounwind_fmt
   7: core::panicking::panic_misaligned_pointer_dereference
   8: script::dom::bindings::conversions::private_from_object
   9: script::dom::node::from_untrusted_node_address
  10: script::dom::document::Document::handle_mouse_move_event
  11: script::script_thread::ScriptThread::update_the_rendering
  12: script::script_thread::ScriptThread::handle_msgs
  13: script::script_thread::ScriptThread::start
  14: profile_traits::mem::ProfilerChan::run_with_memory_reporting
  15: std::sys::backtrace::__rust_begin_short_backtrace
  16: core::ops::function::FnOnce::call_once{{vtable.shim}}
  17: std::sys::pal::unix::thread::Thread::new::thread_start
  18: start_thread
  19: __GI___clone3
[2024-12-18T13:50:54Z ERROR servoshell::panic_hook] misaligned pointer dereference: address must be a multiple of 0x8 but is 0x4b4b4b4b4b4b4b4b

To Reproduce:

  • ./mach run -r discord.com/login --pref "dom.intersection_observer.enabled"
  • Move your mouse a bit. (not sure if necessary)
  • The crash should happen within 1-2 seconds of the page loading

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I have a patch for this which I’m cleaning up for review. Our enumerate_global function is doing a lot more work than is required—we just need to enumerate the names of the WebIDL interfaces that are exposed; we don’t actually need to instantiate them. This avoids the whole issue of the realm, since no new objects are created.

So I theorize that the JS is doing something like Object.keys(someIframe.contentWindow), which enumerates all properties of the window and causes us to run the code that defines the properties for all known bindings in the realm of the caller.

I think this is right on the money! The following html fails with the same assertion failure:

<html>
  <body>
    <iframe id="if"></iframe>
    <script>
          const frame = document.getElementById('if').contentWindow;
          for (const i of Object.getOwnPropertyNames(frame)) {
            console.log('checking', i);
            try {
              frame[i]['foo'];
            } catch (e) {
            }
          }
    </script>
  </body>
</html>

If I replace the for loop with a simple frame['location']['foo'], there is no failure.

I’ve filed #34709 for that, since it’s not clear to me that it’s the same issue that discord is exposing.