Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write fully safe Rust bindings to SpiderMonkey #8732

Closed
DemiMarie opened this issue Nov 29, 2015 · 6 comments
Closed

Write fully safe Rust bindings to SpiderMonkey #8732

DemiMarie opened this issue Nov 29, 2015 · 6 comments
Assignees
Labels

Comments

@DemiMarie
Copy link

@DemiMarie DemiMarie commented Nov 29, 2015

The Rust bindings to SpiderMonkey are not really safe, even with the plugins. Layout must use unsafe accessors, asserts to prevent undefined behavior are not present in release builds, and the compiler plugins do not prevent all errors involving purely safe code.

One solution to this is to provide fully safe Rust bindings to SpiderMonkey. This seems (to me) to involve:

  • Using the type system to ensure that the correct JSContext is passed to the JSAPI.
  • Using the type system and/or a better compiler plugin to ensure that types like Rooted<T> are not misused. In particular, they should not be allowed as generic type parameters.
  • Creating a container that can hold any number of Javascript objects, together with an arbitrary Rust payload, and use it for all heap-allocated objects containing Javascript values. Alternatively, make the existing unrooted_must_root lint sound.
  • Look at the unsafe code generated by the WebIDL bindings. Can it be replaced by safe code?
  • Packaging all of this up in such a way as to be useable by other Rust libraries and programs, not just Servo.
@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Nov 29, 2015

While this would be nice, it is not a priority for us.

@jdm jdm added the I-safety label Nov 29, 2015
@DemiMarie
Copy link
Author

@DemiMarie DemiMarie commented Nov 29, 2015

I think I understand – in a web browser there is more to security than just memory safety.

@nox
Copy link
Member

@nox nox commented Sep 30, 2017

@asajeffrey asajeffrey self-assigned this Oct 2, 2017
@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Oct 2, 2017

This is the goal of https://github.com/asajeffrey/linjs we shall see if it scales to something the size of servo!

@dralley
Copy link
Contributor

@dralley dralley commented Mar 24, 2020

Related to this? #8079

@jdm
Copy link
Member

@jdm jdm commented Mar 24, 2020

I don't see a compelling reason to keep this issue open. It would be better to file more specific issues in https://github.com/servo/rust-mozjs.

@jdm jdm closed this Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.