Skip to content

Commit e1893c0

Browse files
authored
Fix alignment of poll subscriptions (#42)
_Alignof(__wasi_subscription_t) is 8. wasmtime actually rejects misaligned addresses. The problem pointed out by sunfishcode: bytecodealliance/wasmtime#5891 (comment) Fixes #39
1 parent b958fca commit e1893c0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

test/testsuite/wasi_threads_exit_main_wasi.wat

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
;;
44
;; linear memory usage:
55
;; 0: wait
6-
;; 100: poll_oneoff subscription
7-
;; 200: poll_oneoff event
8-
;; 300: poll_oneoff return value
6+
;; 0x100: poll_oneoff subscription
7+
;; 0x200: poll_oneoff event
8+
;; 0x300: poll_oneoff return value
99

1010
(module
1111
(memory (export "memory") (import "foo" "bar") 1 1 shared)
@@ -15,13 +15,13 @@
1515
(func (export "wasi_thread_start") (param i32 i32)
1616
;; long enough block
1717
;; clock_realtime, !abstime (zeros)
18-
i32.const 124 ;; 100 + offsetof(subscription, timeout)
18+
i32.const 0x118 ;; 0x100 + offsetof(subscription, timeout)
1919
i64.const 1_000_000_000 ;; 1s
2020
i64.store
21-
i32.const 100 ;; subscription
22-
i32.const 200 ;; event (out)
21+
i32.const 0x100 ;; subscription
22+
i32.const 0x200 ;; event (out)
2323
i32.const 1 ;; nsubscriptions
24-
i32.const 300 ;; retp (out)
24+
i32.const 0x300 ;; retp (out)
2525
call $poll_oneoff
2626
unreachable
2727
)

test/testsuite/wasi_threads_exit_nonmain_wasi.wat

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
;;
44
;; linear memory usage:
55
;; 0: wait
6-
;; 100: poll_oneoff subscription
7-
;; 200: poll_oneoff event
8-
;; 300: poll_oneoff return value
6+
;; 0x100: poll_oneoff subscription
7+
;; 0x200: poll_oneoff event
8+
;; 0x300: poll_oneoff return value
99

1010
(module
1111
(memory (export "memory") (import "foo" "bar") 1 1 shared)
@@ -41,13 +41,13 @@
4141
end
4242
;; long enough block
4343
;; clock_realtime, !abstime (zeros)
44-
i32.const 124 ;; 100 + offsetof(subscription, timeout)
44+
i32.const 0x118 ;; 0x100 + offsetof(subscription, timeout)
4545
i64.const 1_000_000_000 ;; 1s
4646
i64.store
47-
i32.const 100 ;; subscription
48-
i32.const 200 ;; event (out)
47+
i32.const 0x100 ;; subscription
48+
i32.const 0x200 ;; event (out)
4949
i32.const 1 ;; nsubscriptions
50-
i32.const 300 ;; retp (out)
50+
i32.const 0x300 ;; retp (out)
5151
call $poll_oneoff
5252
unreachable
5353
)

0 commit comments

Comments
 (0)