We went to RustConf last Saturday, and it was AWESOME.

Malisa is sick
and focused on getting better ![]()
Things we did:
- Updating Headers
- A PR that Jeena opened a while ago finally got merged after fetch web platform test was updated.
- Promise in Fetch
- On Friday, wrapping
Rc<Promise>withTrusteddidn’t work. Over the weekend Josh pushed another commit to enableTrusted<Promise>andTrustedPromise::root()that will return aRc<Promise>. On Sunday, I encountered two borrow check errors:- process_response requires
&mut selfas a parameter (not mut self). When I try to get the root ofTrustedPromise, it throws an error saying “cannot move out of borrowed content”. lines 122, 124, 136, and 138 - the
root()ofTrustedPromiserequires self parameter. In line 101, withlet context = fetch_context.lock().unwrap();which is typeMutexGuard, which derefs to &T. When we try to access theRc<Promise>viacontext.fetch_promise.root(), the compiler throws a borrow error.
- process_response requires
- Today, I struggled a lot with the borrow checker, but now I have a compiling code! So I wrote a short html page that uses fetch to run it on Servo! (Based on MDN’s example)
- That helped me learn that Fetch isn’t working
. I started debugging (which means, me = stressed out) and learned a few things:
-
metadatathat is used forprocess_responselooks good. It’sOk(_)and has the fields that look not incorrect. - After promise is taken from FetchContext through
self.fetch_promise.take(), no other line is called… WEIRD. WHY. Well, luckily, I was working at the Mozilla Office, and three(!) people helped me debug. Special thanks to @sanxiyn, @fitzgen, and @jimblandy.
-
- So, after using the debugger, this is what we learned:
- Here is the stack backtrace.
- Frame is older with higher frame number, i.e.
frame #6is called beforeframe #5. -
frame #6shows thatto_jsvalwas called. This in turn callsJS_WrapValueinframe #5. This in turn callsJSCompartment::wrapinframe #4. -
JSCompartment::wrapis a C++ code in SpiderMonkey, a JavaScript engine.JSCompartment::wraphas a parameter that isthis=&0x0.0x0is a null pointer!!! We have a memory-unsafety here!!! Woohoo!
- On Friday, wrapping
- Body
- Read the spec and some more about Unicode encodings in order to understand the UTF-8 decoder. Wrote a little code. Progress was slow due to being sick today.
Things we learned:
- When you write
.after an object, it automatically derefs! For example, if I dofetch_context.lock(), I’m derefingfetch_contextthen applying thelock()method. - assigning different types to the same binding name (via let statements) seems to be acceptable practice, at least in some contexts.
-
0x0is the synonym to null pointer in C++! If your stack backtrace includes0x0that’s probably not something you wanted :) - When debugging Servo, you can use the
--debugtag, i.e../mach run -d ~/src/fetch_example.html --debug. Servo uses lldb debugger by default. - You can set a breakpoint, for example, if you want the code to pause when it calls
rust_panicfunction, you can writeb rust_panic<ENTER>run. - While you’re at the breakpoint, (or maybe some other time too but I’m not too sure) you can type
btwhich will print all the backtrace! COOL. -
RcandTrustedhas to maintain a 1:1 relationship, and therefore,Trustedshould not have a&selfparameter because that could break that 1:1 constraint. In Servo’s promise,Rccounts the references, and thereforeTrustedPromisehas to be connected to the one and onlyRc<Promise>, because otherwise, the reference count will be incorrect.
TODO:
- Promise in Fetch
- Ask jdm about the null pointer!
- Body
- continue with UTF-8’s decoder