mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +00:00
compiler: fix passing weirdly-padded structs to new goroutines
The values were stored in the passed object as the values itself (not expanded like is common in the calling convention), and read back after assuming they were expanded. This often works for simple parameters (int, pointer, etc), but not for more complex parameters. Especially when there's padding. Found this while working on `//go:wasmexport`.
This commit is contained in:
committed by
Ron Evans
parent
ee5bc65c97
commit
d4cb92f27c
Vendored
+16
@@ -86,6 +86,10 @@ func main() {
|
||||
testCond()
|
||||
|
||||
testIssue1790()
|
||||
|
||||
done := make(chan int)
|
||||
go testPaddedParameters(paddedStruct{x: 5, y: 7}, done)
|
||||
<-done
|
||||
}
|
||||
|
||||
func acquire(m *sync.Mutex) {
|
||||
@@ -243,3 +247,15 @@ func (f Foo) Wait() {
|
||||
time.Sleep(time.Microsecond)
|
||||
println(" ...waited")
|
||||
}
|
||||
|
||||
type paddedStruct struct {
|
||||
x uint8
|
||||
_ [0]int64
|
||||
y uint8
|
||||
}
|
||||
|
||||
// Structs with interesting padding used to crash.
|
||||
func testPaddedParameters(s paddedStruct, done chan int) {
|
||||
println("paddedStruct:", s.x, s.y)
|
||||
close(done)
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -26,3 +26,4 @@ called: Foo.Nowait
|
||||
called: Foo.Wait
|
||||
...waited
|
||||
done with 'go on interface'
|
||||
paddedStruct: 5 7
|
||||
|
||||
Reference in New Issue
Block a user