design icon indicating copy to clipboard operation
design copied to clipboard

Lack of Watchpoints

Open alexanderkyte opened this issue 7 years ago • 0 comments

WebAssembly is billed as a target to compile low-level code to. Low-level code almost universally uses manual memory management. When debugging applications which contain memory errors, it is often impossible to track down a bug without watchpoints. In an application with hundreds of places that mutate shared memory, it is easy for memory unsafety in one function to result in a crash much later in a different function.

If WebAssembly's ArrayBuffers enabled extension though Proxy or method override, it would be possible to implement watchpoints in JS. I'm sure that optimizing JIT compilers would have issue with this though, as that would result in needing to recompile and deoptimize code on the fly.

If WebAssembly offered watchpoints as a first-class dev tool feature, the JITs' desire to not offer high-level indirection on memory writes would not clash with API consumers' need for memory debugging aids.

This would probably be implemented by setting actual watchpoints on the underlying memory (that would have to be fixed up if the buffer were moved by the GC). The overhead would thus be comparable to setting a C watchpoint.

alexanderkyte avatar Nov 18 '17 05:11 alexanderkyte