servo/components
bors-servo 0916ae3b3a
Auto merge of #27042 - KallynGowdy:js-backtrace-build-fix, r=jdm
Fix building with --feature js_backtrace

This PR fixes an build error that I ran into when using the `--features js_backtrace` flag.

In particular, the error I ran into was this:
```
error[E0061]: this function takes 2 arguments but 1 argument was supplied
   --> components\script\dom\bindings\error.rs:113:45
    |
113 |         let js_stack = stack.and_then(|s| s.as_string(None));
    |                                             ^^^^^^^^^ ---- supplied 1 argument
    |                                             |
    |                                             expected 2 arguments
```

It seems that the `mozjs` crate updated the [`as_string()` method on `CapturedJSStack`](https://doc.servo.org/mozjs/rust/struct.CapturedJSStack.html#method.as_string) to take two parameters. I've chosen to use `StackFormat::Default` because that will presumably preserve the original intended behavior.

I additionally had to make the block wrapping the feature unsafe as I ran into a "must be marked as unsafe to call unsafe code" build error after fixing the above issue. Seems that this commit (0703a1ad6d) forgot that part.

#### Other Notes

After these changes, I was able to build but ran into an access violation error during runtime. When a JS error hit [`throw_dom_exception()`](https://github.com/servo/servo/blob/master/components/script/dom/bindings/error.rs#L109) and the JS stack was pulled, some sort of issue was hit inside mozjs and [`MOZ_NoReturn()`](bdccbdc656/mozjs/mfbt/Assertions.h (L235)) was called, which will obviously cause an issue.

It is worth noting that this only happened on my test platform (Hololens 2) and not on MacOS or in the Hololens 2 emulator. Additionally, the debug logs were not particularly helpful at identifying the culprit. Maybe it is worth making a full issue for?

Here's the full details:

Error message:
```
Exception thrown at 0x00007FFBCDD16784 (simpleservo.dll) in ServoApp.exe: 0xC0000005: Access violation writing location 0x0000000000000000.
```

Stack Trace:
```
simpleservo.dll!MOZ_NoReturn(int aLine) Line 236
	at E:\Projects\Yeti\servo\target\aarch64-uwp-windows-msvc\debug\build\mozjs_sys-aa48eb6c20c205d4\out\build\dist\include\mozilla\Assertions.h(236)
simpleservo.dll!js::SavedStacks::insertFrames(JSContext * cx, JS::MutableHandle<js::SavedFrame *> frame, mozilla::Variant<JS::AllFrames,JS::MaxFrames,JS::FirstSubsumedFrame> && capture) Line 0
	at E:\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2d\9a6d8fc\mozjs\js\src\vm\SavedStacks.cpp(0)
simpleservo.dll!js::SavedStacks::saveCurrentStack(JSContext * cx, JS::MutableHandle<js::SavedFrame *> frame, mozilla::Variant<JS::AllFrames,JS::MaxFrames,JS::FirstSubsumedFrame> && capture) Line 1292
	at E:\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2d\9a6d8fc\mozjs\js\src\vm\SavedStacks.cpp(1292)
simpleservo.dll!JS::CaptureCurrentStack(JSContext * cx, JS::MutableHandle<JSObject *> stackp, mozilla::Variant<JS::AllFrames,JS::MaxFrames,JS::FirstSubsumedFrame> && capture) Line 5926
	at E:\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2d\9a6d8fc\mozjs\js\src\jsapi.cpp(5926)
simpleservo.dll!mozjs::rust::CapturedJSStack::new(mozjs::rust::RootedGuard<mut mozjs_sys::generated::root::JSObject*> cx, core::option::Option<u32> guard) Line 1337
	at E:\.cargo\git\checkouts\rust-mozjs-8611526964119dd6\28248e1\src\rust.rs(1337)
simpleservo.dll!script::dom::bindings::error::throw_dom_exception(script::script_runtime::JSContext cx, script::dom::globalscope::GlobalScope * global, script::dom::bindings::error::Error result) Line 114
	at E:\Projects\Yeti\servo\components\script\dom\bindings\error.rs(114)
```

Repro:

1. Make a build on Windows for the Hololens 2.
    -   This is the command I used: `C:\Python27\python.exe mach build -d --uwp --win-arm64 --features js_backtrace`
2. Open the project in Visual Studio.
3. Change the default URL in `DefaultUrl.h` to `"http://yeticgi.casualos.com/?story=test1&pagePortal=home"`.
    - Note the lack of HTTPS. There's a separate issue that causes a websocket error. Was trying to debug when I ran into this  issue.
    - The same issue occurs if you load from a build of this [this repository](https://github.com/casual-simulation/casualos). Follow the instructions in [`DEVELOPERS.md`](https://github.com/casual-simulation/casualos/blob/develop/DEVELOPERS.md) if you do.
2. Run on the [Hololens 2 via Visual Studio](https://docs.microsoft.com/en-us/windows/mixed-reality/using-visual-studio#deploying-an-app-over-wi-fi---hololens-2).
    -   If the default URL doesn't take effect, you may have to uninstall the app from the Hololens 2 and reinstall.
3. Wait for it to load and stop at a breakpoint for `SavedStacks.cpp`.
    -   It will say the source cannot be found but its actually because the breakpoint doesn't have a related line in the source code.
    -   If you continue then it will run into the access violation exception.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they fix a build error.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
2020-06-22 20:05:40 -04:00
..
allocator
atoms Add support for remaining animation and transition events 2020-05-26 20:34:58 +02:00
background_hang_monitor Use UnsafeCell instead of static mut in background_hang_monitor/sampler_linux.rs 2020-06-05 00:11:37 +02:00
bluetooth Some Cargo.toml cleanups 2020-05-13 22:09:56 -07:00
bluetooth_traits Some Cargo.toml cleanups 2020-05-13 22:09:56 -07:00
canvas style: fix formatting. 2020-06-18 23:51:18 +02:00
canvas_traits Add support for WebGL2 TexImage2D 2020-06-18 09:59:04 +02:00
compositing Update webrender. 2020-06-11 14:07:39 -04:00
config Embedding API: prefs r/w 2020-06-10 09:38:13 +02:00
config_plugins More Cargo.toml cleanups 2020-05-14 22:20:18 -07:00
constellation Send LoadStart event when the actual pipeline is loading 2020-06-22 07:20:15 +02:00
debugger
deny_public_fields
derive_common style: Gracefully handle errors creating shared memory UA style sheets. 2020-06-04 01:50:36 +02:00
devtools Allow embedder to bypass devtools prompt 2020-06-22 11:47:03 +02:00
devtools_traits More Cargo.toml cleanups 2020-05-14 22:20:18 -07:00
dom_struct
domobject_derive More Cargo.toml cleanups 2020-05-14 22:20:18 -07:00
embedder_traits Allow embedder to bypass devtools prompt 2020-06-22 11:47:03 +02:00
fallible More Cargo.toml cleanups 2020-05-14 22:20:18 -07:00
geometry
gfx Make url for "client" referrer mandatory 2020-06-17 19:07:14 +02:00
gfx_traits Update webrender. 2020-06-11 14:07:39 -04:00
hashglobe More Cargo.toml cleanups 2020-05-14 22:20:18 -07:00
jstraceable_derive
layout Implement GPUSwapChain and GPUCanvasContext and interface with Webrender 2020-06-13 17:46:12 +05:30
layout_2020 Auto merge of #26968 - servo:layout-2020-lazy-content-sizes, r=SimonSapin 2020-06-19 13:50:29 -04:00
layout_thread Add animation and transition support for pseudo-elements 2020-06-16 16:33:55 +02:00
layout_thread_2020 Add animation and transition support for pseudo-elements 2020-06-16 16:33:55 +02:00
layout_traits Remove unecessary webrender document from layout. 2020-06-09 13:05:16 -04:00
malloc_size_of More Cargo.toml updates 2020-05-25 11:34:37 -07:00
media Implement GPUSwapChain and GPUCanvasContext and interface with Webrender 2020-06-13 17:46:12 +05:30
metrics Remove support for energy profiling 2020-06-04 16:39:08 +02:00
msg Remove some unused dependency declarations 2020-05-29 00:04:34 +02:00
net Fix remaining flake8 warnings 2020-06-21 03:34:32 +02:00
net_traits Make url for "client" referrer mandatory 2020-06-17 19:07:14 +02:00
pixels More Cargo.toml updates 2020-05-30 18:18:57 -07:00
profile Remove support for heartbeats profiling 2020-06-04 22:53:56 +02:00
profile_traits Remove support for heartbeats profiling 2020-06-04 22:53:56 +02:00
rand
range More Cargo.toml updates 2020-05-30 18:18:57 -07:00
remutex Fix rust's remutex source code link 2020-06-01 21:24:05 +09:00
script Auto merge of #27042 - KallynGowdy:js-backtrace-build-fix, r=jdm 2020-06-22 20:05:40 -04:00
script_layout_interface Auto merge of #26921 - mrobinson:animation-set-key, r=jdm 2020-06-16 03:25:29 -04:00
script_plugins
script_traits Make url for "client" referrer mandatory 2020-06-17 19:07:14 +02:00
selectors style: Rustfmt recent changes. 2020-06-04 02:02:50 +02:00
servo Implement GPUSwapChain and GPUCanvasContext and interface with Webrender 2020-06-13 17:46:12 +05:30
servo_arc More Cargo.toml updates 2020-05-30 18:18:57 -07:00
size_of_test
std_test_override
style Fix remaining flake8 warnings 2020-06-21 03:34:32 +02:00
style_derive style: Rustfmt recent changes. 2020-06-04 02:02:50 +02:00
style_traits style: Miscellaneous servo build fixes. 2020-06-04 01:50:36 +02:00
to_shmem style: Gracefully handle errors creating shared memory UA style sheets. 2020-06-04 01:50:36 +02:00
to_shmem_derive style: Gracefully handle errors creating shared memory UA style sheets. 2020-06-04 01:50:36 +02:00
url style: Miscellaneous servo build fixes. 2020-06-04 01:50:36 +02:00
webdriver_server Make url for "client" referrer mandatory 2020-06-17 19:07:14 +02:00
webgpu Update wgpu-core and wgpu-types 2020-06-19 11:12:50 +05:30
webrender_surfman Update surfman to 0.2 and remove glutin 2020-04-17 23:44:53 -05:00
webrender_traits Implement GPUSwapChain and GPUCanvasContext and interface with Webrender 2020-06-13 17:46:12 +05:30