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
I-safety Some piece of code violates memory safety guarantees.

Comments

@DemiMarie
Copy link

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 commented Nov 29, 2015

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

@jdm jdm added the I-safety Some piece of code violates memory safety guarantees. label Nov 29, 2015
@DemiMarie
Copy link
Author

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

@nox
Copy link
Contributor

nox commented Sep 30, 2017

Cc @asajeffrey

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

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 commented Mar 24, 2020

Related to this? #8079

@jdm
Copy link
Member

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 as completed Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-safety Some piece of code violates memory safety guarantees.
Projects
None yet
Development

No branches or pull requests

6 participants