Re: GSoC'17 - Introduction: Rustify GJS

Hey Luke,

Nice to have you!

I just wanted to be picky and correct something :) On your example with rust, you put the declaration inside a different scope. This won't work in C either or any other language, that's not an use after free.
What you want is to define the variable outside of that scope, assign it to a new memory chunk inside a different scope, then outside of that scope try to acces the same var. That would be a use-after-free.

Carlos Soriano

On Sun, May 7, 2017 at 11:31 PM, Luke Jones <luke nukem jones gmail com> wrote:
Hello all,

I am Luke Jones, a student of software engineering in New Zealand.

The project proposal of mine that was accepted is to research and
implement the Rust language in to GJS to help reduce or eliminate
memory leaks and increase memory safety.

GJS is something that some rather important parts of the GNOME
ecosystem rely on (eg, shell), and it is imperative that it be solid,
stable, fast - as we all know, while C and C++ are wonderful languages
in their own right, they also allow many flaws to sneak past simply by
virtue of giving the programmer incredible unchecked power. This has
in the past introduced such things as memory leaks (not freeing after
use), use after free, array out of bounds and so on.

And then we have the cool new kid on the block; Rust.

Where the power of Rust comes in to play is via its compiler - it
enforces a set of rules regarding the ownership of data;
* data is immutable by default
* data may have any number of references (pointers) to it for as long
as the data is within scope of those references, or;
* data may only have one mutable reference
* if data is /moved/ it is no-longer able to be referenced by a
previous reference, and the compiler checks this.
* data /must/ have a value - null does not exist

The above means that such things as use-after-free are almost
impossible, as the compiler checks that the data is within scope and
throws an error if not. You can see a small demo here

The aim of my project is to investigate a number of things;
* interoperation of C/C++ and Rust - Rust has an FFI
* the replacement of small sections of C/C++ with Rust
* the impact this has on such things as performance, memory safety, memory use

The ultimate goal after this is to open the way for using Rust within
GJS for mission critical sections - dependant on results of course -
and hopefully inspire others to start their own investigations in to
use of Rust within their projects.


I'm looking forward to seeing the benefits of this, and other
projects. Exciting times.

Oh, and yes there was the recent GNOME+Rust Hackfest, and also librsvg
slowly converting to Rust - I hope to be able to use this knowledge
base, as well as contribute to it.
gnome-soc-list mailing list
gnome-soc-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]