]> Cypherpunks.ru repositories - gostls13.git/commitdiff
misc/wasm: ensure correct stack pointer in catch clauses
authorRichard Musiol <mail@richard-musiol.de>
Sun, 23 May 2021 21:06:43 +0000 (23:06 +0200)
committerRichard Musiol <neelance@gmail.com>
Mon, 24 May 2021 22:12:19 +0000 (22:12 +0000)
The stack pointer may have changed after a call from JavaScript into Go
code because of stack growth. The normal case already updated the
sp variable accordingly, but the catch case did not yet.

Fixes #45433

Change-Id: I3e0a33381929626f6b21902948935eb5ffb26c96
Reviewed-on: https://go-review.googlesource.com/c/go/+/321936
Trust: Richard Musiol <neelance@gmail.com>
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
misc/wasm/wasm_exec.js

index 3e41e628ef9de482d2d137a1631edc09d58f80fa..231185a123ed12f8bc6b2ad7a56a00e3615a656a 100644 (file)
                                                        storeValue(sp + 56, result);
                                                        this.mem.setUint8(sp + 64, 1);
                                                } catch (err) {
+                                                       sp = this._inst.exports.getsp() >>> 0; // see comment above
                                                        storeValue(sp + 56, err);
                                                        this.mem.setUint8(sp + 64, 0);
                                                }
                                                        storeValue(sp + 40, result);
                                                        this.mem.setUint8(sp + 48, 1);
                                                } catch (err) {
+                                                       sp = this._inst.exports.getsp() >>> 0; // see comment above
                                                        storeValue(sp + 40, err);
                                                        this.mem.setUint8(sp + 48, 0);
                                                }
                                                        storeValue(sp + 40, result);
                                                        this.mem.setUint8(sp + 48, 1);
                                                } catch (err) {
+                                                       sp = this._inst.exports.getsp() >>> 0; // see comment above
                                                        storeValue(sp + 40, err);
                                                        this.mem.setUint8(sp + 48, 0);
                                                }