Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 15 Dec 2017 13:04:14 +0000
From: Nicholas Wilson <nicholas.wilson@...lvnc.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: Re: [PATCH] split __libc_start_main.c into two files (Wasm)

Hi,

On 15 December 2017 12:33, Szabolcs Nagy wrote:
> why is exit ugly?
> halting execution should not be complicated on whatever platform

In WebAssembly, the runtime environment is (typically) a webpage. It's not clear what exit() would be expected to do to the webpage or Wasm module. The Wasm interpreter offered by browsers doesn't offer a way to cleanly exit/terminate a running WebAssembly function; the "trap" instruction to abort is the closest you could get.

If you have some existing C code that you want to compile/port to WebAssembly, whatever the code previously expects to happen on exit() won't happen. It will need to be changed when ported to the web, the semantics of a Unix process and a web page are unavoidably different. For brand-new code specifically targeting a web page, you wouldn't deliberately add a dependency on exit(), because it's not clearly meaningful for a webpage.

So, it's "ugly" to me because the lifecycle of the webpage is an awkward fit for exit(). We could bodge in some emulation, but it's just ugly to pull in the emulation when we don't expect it to be used. My preference is "you should only link in the hacks you rely on".

It's not too bad - we will have to implement exit() emulation for legacy code, so I could live with it being linked in to every application. I just dislike hacks, and don't enjoy seeing them bundled into my own applications!

> how do you implement a_crash?
> the c runtime uses that all over the place anyway so it's unlikely
> that you can get away without process termination code.

a_crash will invoke the Wasm "trap" instruction, which throws an exception up to the WebAssembly interpreter. It will have proper "noreturn" semantics, but it's then up to the interpreter to do whatever it feels is most helpful to the developer - probably print a message.

Nick

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.