Skip to content

Conversation

@Yaxuan-w
Copy link
Member

@Yaxuan-w Yaxuan-w commented Oct 15, 2025

This PR refactors grate execution flow mentioned in issue #442.

Previously, the Wasm instance creation logic passed the closure directly to 3i, which then performed registration separately. In this PR, the closure is now passed as an argument to register_handler(), allowing 3i to perform both the registration and runtime binding internally.

This change:

  1. simplifies the integration path and makes the 3i API adaptable to different runtime environments (e.g., Wasmtime, MPK, or future runtime backends).
  2. removes closure usage in wasmtime <-> 3i

More details in code comments

Add grate tests examples as described in issue #468

@github-actions
Copy link
Contributor

End-to-End Test Report

Test Preview

Test Report

Deterministic Tests

Summary

MetricCount
Total Test Cases33
Number of Successes33
Number of Failures0
Number of Compilation Failure Native0
Number of Runtime Failure Native0
Number of Segmentation Fault Native0
Number of Timeout During Native0
Number of Lind Wasm Compile Failure0
Number of Lind Wasm Runtime Failure0
Number of Lind Wasm Segmentation Failure0
Number of Timeout During Lind Wasm run0
Number of Unknown Failure0
Number of GCC and Wasm Output mismatch0

Test Results by Category

Test CaseStatusError TypeOutput
Config Tests
dnstest.cSuccessNone
is sockfd valid? yes
37 is the length sent
53 is the length recieved
the dns lookup yields the ip address: 35.172.89.115
File Tests
doubleclose.cSuccessNone
dupwrite.cSuccessNone
write succeeded
ioctl.cSuccessNone
[For 0 = False and  = True]
[The answers should be F, T, F]

(0) Is the socket set for non-blocking I/O?: 0
[Setting socket for non_blocking I/O]
(1) Is the socket set for non-blocking I/O?: 2048
[Clearing socket for non-blocking I/O]
(2) Is the socket set for non-blocking I/O?: 0

printf.cSuccessNone
Hello, World!
write.cSuccessNone
Hello world from Coulson's WASM
writeloop.cSuccessNone
write succeeded
writepartial.cSuccessNone
write
Memory Tests
brk.cSuccessNone
PASS
malloc.cSuccessNone
memcpy.cSuccessNone
Hello, World!
mmap_shared.cSuccessNone
parent value: 1234, 4321
parent value after fork: 1234, 4321
child value after fork: 1234, 4321
parent value after modification: 2333, 3332
child value after modification: 2333, 4321
mprotect.cSuccessNone
Mprotect write test text
sbrk.cSuccessNone
Content in allocated memory: Hello, sbrk memory!
shmtest.cSuccessNone
Networking Tests
makepipe.cSuccessNone
poll.cSuccessNone
stdout is ready for writing.
recvfrom-sendto.cSuccessNone
Client sent: Hello recvfrom!
simple_epoll.cSuccessNone
waiting for epoll event...
got data: hello epoll!

socket.cSuccessNone
Socket opened succesfully.
socket_cloexec.cSuccessNone
SOCK_CLOEXEC is set.
socketpair.cSuccessNone
-->In Xanadu, did Kublai Khan . . .
-->A stately pleasure dome decree . . .
tcp_connect_single.cSuccessNone
Process Tests
chain_thread.cSuccessNone
Outer thread running...
Inner thread running...
Inner thread done.
Outer thread done.
Main thread done.
exit.cSuccessNone
Exiting...

function-ptr.cSuccessNone
Hello, World!
hello.cSuccessNone
wark
noforkfiles.cSuccessNone
signal-fork.cSuccessNone
Successfully changed the signal handler for Signal 12
Killing Child
Signal Handler Test!
Exiting Child
thread-test.cSuccessNone
Hello from the thread!
Thread has finished execution
thread.cSuccessNone
Hello from thread
wait.cSuccessNone
Parent detected child finished.
Child exited with status 0
waitpid_wnohang.cSuccessNone
Non Deterministic Tests

Summary

MetricCount
Total Test Cases20
Number of Successes20
Number of Failures0
Number of Compilation Failure Native0
Number of Runtime Failure Native0
Number of Segmentation Fault Native0
Number of Timeout During Native0
Number of Lind Wasm Compile Failure0
Number of Lind Wasm Runtime Failure0
Number of Lind Wasm Segmentation Failure0
Number of Timeout During Lind Wasm run0
Number of Unknown Failure0
Number of GCC and Wasm Output mismatch0

Test Results by Category

Test CaseStatusError TypeOutput
Config Tests
gethostname.cSuccessNone
Hostname: buildkitsandbox
sysconf.cSuccessNone
calling sysconf(sysconf())
File Tests
chdir_getcwd.cSuccessNone
getcwd() error: Success
getcwd() error: Success
clock_gettime_highlevel.cSuccessNone
Running 1,000,000 iterations...

Start time: 4327 clock ticks
End time: 6597 clock ticks
Elapsed CPU time: 0.00227 seconds

clock_gettime_simple.cSuccessNone
Current time: 1760561701 seconds and 897610663 nanoseconds
dup.cSuccessNone
duped fd: 3
attempting to write to dup() fd

write to dup() fd succeeded
write to old fd succeeded

fchdir.cSuccessNone
getcwd() error: Success
fstatfs.cSuccessNone
Error in open()
: No such file or directory
getcwd.cSuccessNone
getcwd() error: Success
read.cSuccessNone
open(): No such file or directory
statfs.cSuccessNone
Error in statfs
: No such file or directory
Memory Tests
mmap_complicated.cSuccessNone
Child: Writing to shared memory.
Parent: Waiting for child to write.
Parent: Reading from shared memory: 'Hello from the child process!'
Child: Reading from shared memory: 'Hello from the parent process!'
Child: Exiting.
Parent: Reading modified shared memory: 'Hello from the parent process!'
Parent: Exiting.
shm.cSuccessNone
Shared memory segment created with id: 1
Parent attached to shared memory at 0xffffe000
Parent wrote: 'Hello from parent'
Child attached to shared memory at 0xffffe000
Child reads: 'Hello from parent'
Child detached from shared memory
Parent reads: 'Hello from child'
Parent detached from shared memory
Shared memory segment removed
Networking Tests
pipe.cSuccessNone
pipe() ret: [3, 4]
write() ret: 3
read() ret: 3
hi
pipe2.cSuccessNone
pipe2() ret: [3, 4]
write() ret: 3
read() ret: 3
hi
pipewrite.cSuccessNone
Made pipe with write end 3 and read end 4
wrote 16
write 16
wrote 16
wrote three messages to the pipe
msg 0, length 16: hello, world #1
msg 1, length 16: hello, world #2
msg 2, length 16: hello, world #3
simple-select.cSuccessNone
[child] waiting for data...
[parent] writing message
[child] got data: hello select!

[child] waiting for data...
[child] pipe closed

Process Tests
getpid.cSuccessNone
printing pidSuccess
Signal Tests
signal.cSuccessNone
main starts!
parent in loop, pid=1
child ready to kill
child done kill
Caught signal 10
parent in loop, pid=1
Terminated
signal_int_thread.cSuccessNone
main starts!
Hello from thread
thread sleep
thread sleep
child ready to kill
child done kill
child in loop, pid=2
Terminated
Terminated
child in loop, pid=2
child in loop, pid=2
child in loop, pid=2
child in loop, pid=2

@rennergade
Copy link
Contributor

This looks good from my first pass. I'm tagging Justin on this one since this probably needs his final review.

JustinCappos
JustinCappos previously approved these changes Oct 15, 2025
Copy link
Member

@JustinCappos JustinCappos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really still don't understand the closure part, but the rest seems fine. I am about to get on a flight and so will follow up when I have time on that front.

use sysdefs::constants::{
MAP_ANONYMOUS, MAP_PRIVATE, PAGESHIFT, PAGESIZE, PROT_EXEC, PROT_NONE, PROT_READ, PROT_WRITE,
}; // Used in `copy_data_between_cages`
use sysdefs::constants::{PROT_READ, PROT_WRITE}; // Used in `copy_data_between_cages`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely be hidden with a helper function exposed by vmmap to tell you what you really want to know (whether a range is accessible).

@JustinCappos
Copy link
Member

JustinCappos commented Oct 15, 2025 via email

@Yaxuan-w
Copy link
Member Author

putting a reference to the data you're putting in the closure in a table indexed by thread ID should remove the need for the closure

I think one possible solution is:

  1. define a C-ABI callback in Wasmtime (essentially the same logic that’s now inside the closure) and store the required context on the heap;
  2. pass both the function pointer and the context pointer to 3i;
  3. let 3i look up the pid/tid, retrieve the function/context pointers, and invoke the function directly.

I’ll give this approach a try if that sounds reasonable.

@github-actions
Copy link
Contributor

End-to-End Test Report

Test Preview

Test Report

Deterministic Tests

Summary

MetricCount
Total Test Cases34
Number of Successes34
Number of Failures0
Number of Compilation Failure Native0
Number of Runtime Failure Native0
Number of Segmentation Fault Native0
Number of Timeout During Native0
Number of Lind Wasm Compile Failure0
Number of Lind Wasm Runtime Failure0
Number of Lind Wasm Segmentation Failure0
Number of Timeout During Lind Wasm run0
Number of Unknown Failure0
Number of GCC and Wasm Output mismatch0

Test Results by Category

Test CaseStatusError TypeOutput
File Tests
doubleclose.cSuccessNone
dupwrite.cSuccessNone
write succeeded
ioctl.cSuccessNone
[For 0 = False and  = True]
[The answers should be F, T, F]

(0) Is the socket set for non-blocking I/O?: 0
[Setting socket for non_blocking I/O]
(1) Is the socket set for non-blocking I/O?: 2048
[Clearing socket for non-blocking I/O]
(2) Is the socket set for non-blocking I/O?: 0

printf.cSuccessNone
Hello, World!
write.cSuccessNone
Hello world from Coulson's WASM
writeloop.cSuccessNone
write succeeded
writepartial.cSuccessNone
write
Memory Tests
brk.cSuccessNone
PASS
malloc.cSuccessNone
memcpy.cSuccessNone
Hello, World!
mmap_shared.cSuccessNone
parent value: 1234, 4321
parent value after fork: 1234, 4321
child value after fork: 1234, 4321
parent value after modification: 2333, 3332
child value after modification: 2333, 4321
mprotect.cSuccessNone
Mprotect write test text
sbrk.cSuccessNone
Content in allocated memory: Hello, sbrk memory!
shmtest.cSuccessNone
Networking Tests
gethostname.cSuccessNone
Hostname: buildkitsandbox
makepipe.cSuccessNone
poll.cSuccessNone
stdout is ready for writing.
recvfrom-sendto.cSuccessNone
Client sent: Hello recvfrom!
simple_epoll.cSuccessNone
waiting for epoll event...
got data: hello epoll!

socket.cSuccessNone
Socket opened succesfully.
socket_cloexec.cSuccessNone
SOCK_CLOEXEC is set.
socketpair.cSuccessNone
-->In Xanadu, did Kublai Khan . . .
-->A stately pleasure dome decree . . .
tcp_connect_single.cSuccessNone
Process Tests
chain_thread.cSuccessNone
Outer thread running...
Inner thread running...
Inner thread done.
Outer thread done.
Main thread done.
exit.cSuccessNone
Exiting...

function-ptr.cSuccessNone
Hello, World!
hello.cSuccessNone
wark
longjmp.cSuccessNone
In main: Calling first_function...
In first_function: Calling second_function...
In second_function: Performing a long jump...
Back in main: long jump returned with value = 42
noforkfiles.cSuccessNone
signal-fork.cSuccessNone
Successfully changed the signal handler for Signal 12
Killing Child
Signal Handler Test!
Exiting Child
thread-test.cSuccessNone
Hello from the thread!
Thread has finished execution
thread.cSuccessNone
Hello from thread
wait.cSuccessNone
Parent detected child finished.
Child exited with status 0
waitpid_wnohang.cSuccessNone
Non Deterministic Tests

Summary

MetricCount
Total Test Cases20
Number of Successes20
Number of Failures0
Number of Compilation Failure Native0
Number of Runtime Failure Native0
Number of Segmentation Fault Native0
Number of Timeout During Native0
Number of Lind Wasm Compile Failure0
Number of Lind Wasm Runtime Failure0
Number of Lind Wasm Segmentation Failure0
Number of Timeout During Lind Wasm run0
Number of Unknown Failure0
Number of GCC and Wasm Output mismatch0

Test Results by Category

Test CaseStatusError TypeOutput
File Tests
chdir_getcwd.cSuccessNone
getcwd() error: Success
getcwd() error: Success
clock_gettime_highlevel.cSuccessNone
Running 1,000,000 iterations...

Start time: 4370 clock ticks
End time: 6706 clock ticks
Elapsed CPU time: 0.002336 seconds

clock_gettime_simple.cSuccessNone
Current time: 1760572125 seconds and 42166587 nanoseconds
dup.cSuccessNone
duped fd: 3
attempting to write to dup() fd

write to dup() fd succeeded
write to old fd succeeded

fchdir.cSuccessNone
getcwd() error: Success
fstatfs.cSuccessNone
Error in open()
: No such file or directory
getcwd.cSuccessNone
getcwd() error: Success
read.cSuccessNone
open(): No such file or directory
statfs.cSuccessNone
Error in statfs
: No such file or directory
Memory Tests
mmap_complicated.cSuccessNone
Parent: Waiting for child to write.
Child: Writing to shared memory.
Parent: Reading from shared memory: 'Hello from the child process!'
Child: Reading from shared memory: 'Hello from the parent process!'
Child: Exiting.
Parent: Reading modified shared memory: 'Hello from the parent process!'
Parent: Exiting.
shm.cSuccessNone
Shared memory segment created with id: 1
Parent attached to shared memory at 0xffffe000
Parent wrote: 'Hello from parent'
Child attached to shared memory at 0xffffe000
Child reads: 'Hello from parent'
Child detached from shared memory
Parent reads: 'Hello from child'
Parent detached from shared memory
Shared memory segment removed
Networking Tests
dnstest.cSuccessNone
is sockfd valid? yes
37 is the length sent
53 is the length recieved
the dns lookup yields the ip address: 35.172.89.115
getifaddrs.cSuccessNone
getifaddrs: Bad address
pipe.cSuccessNone
pipe() ret: [3, 4]
write() ret: 3
read() ret: 3
hi
pipe2.cSuccessNone
pipe2() ret: [3, 4]
write() ret: 3
read() ret: 3
hi
pipewrite.cSuccessNone
Made pipe with write end 3 and read end 4
wrote 16
write 16
wrote 16
wrote three messages to the pipe
msg 0, length 16: hello, world #1
msg 1, length 16: hello, world #2
msg 2, length 16: hello, world #3
simple-select.cSuccessNone
[child] waiting for data...
[parent] writing message
[child] got data: hello select!

[child] waiting for data...
[child] pipe closed

Process Tests
getpid.cSuccessNone
printing pidSuccess
Signal Tests
signal.cSuccessNone
main starts!
parent in loop, pid=1
child ready to kill
child done kill
Caught signal 10
parent in loop, pid=1
Terminated
signal_int_thread.cSuccessNone
main starts!
Hello from thread
thread sleep
thread sleep
child ready to kill
child done kill
Terminated
child in loop, pid=2
Terminated
child in loop, pid=2
child in loop, pid=2
child in loop, pid=2
child in loop, pid=2

@Yaxuan-w Yaxuan-w requested a review from JustinCappos October 22, 2025 20:26
@github-actions
Copy link
Contributor

End-to-End Test Report

Test Preview

Test Report

Deterministic Tests

Summary

MetricCount
Total Test Cases46
Number of Successes46
Number of Failures0
Number of Compilation Failure Native0
Number of Runtime Failure Native0
Number of Segmentation Fault Native0
Number of Timeout During Native0
Number of Lind Wasm Compile Failure0
Number of Lind Wasm Runtime Failure0
Number of Lind Wasm Segmentation Failure0
Number of Timeout During Lind Wasm run0
Number of Unknown Failure0
Number of GCC and Wasm Output mismatch0

Test Results by Category

Test CaseStatusError TypeOutput
File Tests
doubleclose.cSuccessNone
dupwrite.cSuccessNone
write succeeded
filetest.cSuccessNone
filetest1000.cSuccessNone
ioctl.cSuccessNone
[For 0 = False and  = True]
[The answers should be F, T, F]

(0) Is the socket set for non-blocking I/O?: 0
[Setting socket for non_blocking I/O]
(1) Is the socket set for non-blocking I/O?: 2048
[Clearing socket for non-blocking I/O]
(2) Is the socket set for non-blocking I/O?: 0

printf.cSuccessNone
Hello, World!
write.cSuccessNone
Hello world from Coulson's WASM
writeloop.cSuccessNone
write succeeded
writepartial.cSuccessNone
write
Memory Tests
brk.cSuccessNone
PASS
malloc.cSuccessNone
memcpy.cSuccessNone
Hello, World!
mmap.cSuccessNone
mmap test: PASS
mprotect.cSuccessNone
Mprotect write test text
sbrk.cSuccessNone
Content in allocated memory: Hello, sbrk memory!
shmtest.cSuccessNone
Networking Tests
gethostname.cSuccessNone
Hostname: buildkitsandbox
makepipe.cSuccessNone
pipepong.cSuccessNone
Parent sending 1
Child received 1
Child sends 2
Parent received 2
Parent sending 3
Child received 3
Child sends 4
Parent received 4
Parent sending 5
Child received 5
Child sends 6
Parent received 6
Parent sending 7
Child received 7
Child sends 8
Parent received 8
Parent sending 9
Child received 9
Child sends 10
Parent received 10
Parent sending 11
Child received 11
Child sends 12
Parent received 12
Parent sending 13
Child received 13
Child sends 14
Parent received 14
Parent sending 15
Child received 15
Child sends 16
Parent received 16
Parent sending 17
Child received 17
Child sends 18
Parent received 18
Parent sending 19
Child received 19
Child sends 20
Parent received 20
Parent sending 21
Child received 21
Child sends 22
Parent received 22
Parent sending 23
Child received 23
Child sends 24
Parent received 24
Parent sending 25
Child received 25
Child sends 26
Parent received 26
Parent sending 27
Child received 27
Child sends 28
Parent received 28
Parent sending 29
Child received 29
Child sends 30
Parent received 30
Parent sending 31
Child received 31
Child sends 32
Parent received 32
Parent sending 33
Child received 33
Child sends 34
Parent received 34
Parent sending 35
Child received 35
Child sends 36
Parent received 36
Parent sending 37
Child received 37
Child sends 38
Parent received 38
Parent sending 39
Child received 39
Child sends 40
Parent received 40
Parent sending 41
Child received 41
Child sends 42
Parent received 42
Parent sending 43
Child received 43
Child sends 44
Parent received 44
Parent sending 45
Child received 45
Child sends 46
Parent received 46
Parent sending 47
Child received 47
Child sends 48
Parent received 48
Parent sending 49
Child received 49
Child sends 50
Parent received 50
Parent sending 51
Child received 51
Child sends 52
Parent received 52
Parent sending 53
Child received 53
Child sends 54
Parent received 54
Parent sending 55
Child received 55
Child sends 56
Parent received 56
Parent sending 57
Child received 57
Child sends 58
Parent received 58
Parent sending 59
Child received 59
Child sends 60
Parent received 60
Parent sending 61
Child received 61
Child sends 62
Parent received 62
Parent sending 63
Child received 63
Child sends 64
Parent received 64
Parent sending 65
Child received 65
Child sends 66
Parent received 66
Parent sending 67
Child received 67
Child sends 68
Parent received 68
Parent sending 69
Child received 69
Child sends 70
Parent received 70
Parent sending 71
Child received 71
Child sends 72
Parent received 72
Parent sending 73
Child received 73
Child sends 74
Parent received 74
Parent sending 75
Child received 75
Child sends 76
Parent received 76
Parent sending 77
Child received 77
Child sends 78
Parent received 78
Parent sending 79
Child received 79
Child sends 80
Parent received 80
Parent sending 81
Child received 81
Child sends 82
Parent received 82
Parent sending 83
Child received 83
Child sends 84
Parent received 84
Parent sending 85
Child received 85
Child sends 86
Parent received 86
Parent sending 87
Child received 87
Child sends 88
Parent received 88
Parent sending 89
Child received 89
Child sends 90
Parent received 90
Parent sending 91
Child received 91
Child sends 92
Parent received 92
Parent sending 93
Child received 93
Child sends 94
Parent received 94
Parent sending 95
Child received 95
Child sends 96
Parent received 96
Parent sending 97
Child received 97
Child sends 98
Parent received 98
Parent sending 99
Child received 99
Child sends 100
Parent received 100
Pipe Pong complete.
Final value: 100
poll.cSuccessNone
stdout is ready for writing.
recvfrom-sendto.cSuccessNone
Client sent: Hello recvfrom!
simple_epoll.cSuccessNone
waiting for epoll event...
got data: hello epoll!

socket.cSuccessNone
Socket opened succesfully.
socket_cloexec.cSuccessNone
SOCK_CLOEXEC is set.
socketpair.cSuccessNone
-->In Xanadu, did Kublai Khan . . .
-->A stately pleasure dome decree . . .
tcp_connect_single.cSuccessNone
Process Tests
chain_thread.cSuccessNone
Outer thread running...
Inner thread running...
Inner thread done.
Outer thread done.
Main thread done.
exit.cSuccessNone
Exiting...

forkexecv.cSuccessNone
function-ptr.cSuccessNone
Hello, World!
getppid.cSuccessNone
getppid() succeeded
hello.cSuccessNone
wark
longjmp.cSuccessNone
In main: Calling first_function...
In first_function: Calling second_function...
In second_function: Performing a long jump...
Back in main: long jump returned with value = 42
noforkfiles.cSuccessNone
sem_forks.cSuccessNone
thread-test.cSuccessNone
Hello from the thread!
Thread has finished execution
thread.cSuccessNone
Hello from thread
wait.cSuccessNone
Parent detected child finished.
Child exited with status 0
waitpid_wnohang.cSuccessNone
Signal Tests
alarm.cSuccessNone
Setting an alarm to trigger in 1 seconds...
Alarm triggered! Signal received: 14
Alarm triggered! Signal received: 14
Alarm triggered! Signal received: 14
setitimer.cSuccessNone
Timer started! SIGALRM will fire every 3 seconds.
Timer expired! Signal received: 14
Timer expired! Signal received: 14
Timer expired! Signal received: 14
sigalrm.cSuccessNone
SIGALRM signals blocked
Alarm Handled. Exiting
sigchld.cSuccessNone
Signal Child Test!
signal-fork.cSuccessNone
Successfully changed the signal handler for Signal 12
Killing Child
Signal Handler Test!
Exiting Child
signal-simple.cSuccessNone
Successfully changed the signal handler for Signal 12
Signal Handler Test!
sigprocmask.cSuccessNone
blocking SIGUSR2
Sending SIGUSR2
Sleeping 1 second
unblocking signal
Signal Handler!
Exiting program
Non Deterministic Tests

Summary

MetricCount
Total Test Cases41
Number of Successes40
Number of Failures1
Number of Compilation Failure Native0
Number of Runtime Failure Native0
Number of Segmentation Fault Native0
Number of Timeout During Native0
Number of Lind Wasm Compile Failure0
Number of Lind Wasm Runtime Failure0
Number of Lind Wasm Segmentation Failure0
Number of Timeout During Lind Wasm run1
Number of Unknown Failure0
Number of GCC and Wasm Output mismatch0

Test Results by Category

Test CaseStatusError TypeOutput
File Tests
chdir_getcwd.cSuccessNone
getcwd() error: Success
getcwd() error: Success
clock_gettime_highlevel.cSuccessNone
Running 1,000,000 iterations...

Start time: 6717 clock ticks
End time: 8984 clock ticks
Elapsed CPU time: 0.002267 seconds

clock_gettime_simple.cSuccessNone
Current time: 1761165486 seconds and 871665518 nanoseconds
dup.cSuccessNone
duped fd: 3
attempting to write to dup() fd

write to dup() fd succeeded
write to old fd succeeded

fchdir.cSuccessNone
getcwd() error: Success
fstatfs.cSuccessNone
Error in open()
: No such file or directory
getcwd.cSuccessNone
getcwd() error: Success
read.cSuccessNone
open(): No such file or directory
statfs.cSuccessNone
Error in statfs
: No such file or directory
Memory Tests
malloc_large.cSuccessNone
0xefffe010: 42
mmap_complicated.cSuccessNone
Child: Writing to shared memory.
Parent: Waiting for child to write.
Parent: Reading from shared memory: 'Hello from the child process!'
Child: Reading from shared memory: 'Hello from the parent process!'
Child: Exiting.
Parent: Reading modified shared memory: 'Hello from the parent process!'
Parent: Exiting.
mmap_shared.cSuccessNone
parent value: 1234, 4321
parent value after fork: 1234, 4321
child value after fork: 1234, 4321
parent value after modification: 2333, 3332
child value after modification: 2333, 4321
segfault.cSuccessNone
pipe() ret: [3, 4]
read() ret: 3
hi
shm.cSuccessNone
Shared memory segment created with id: 1
Parent attached to shared memory at 0xffffe000
Parent wrote: 'Hello from parent'
Child attached to shared memory at 0xffffe000
Child reads: 'Hello from parent'
Child detached from shared memory
Parent reads: 'Hello from child'
Parent detached from shared memory
Shared memory segment removed
vtable.cSuccessNone
Shape 0 area: 12
Shape 1 area: 19.635
Networking Tests
dnstest.cSuccessNone
is sockfd valid? yes
37 is the length sent
53 is the length recieved
the dns lookup yields the ip address: 35.172.89.115
getifaddrs.cSuccessNone
getifaddrs: Bad address
pipe.cSuccessNone
pipe() ret: [3, 4]
write() ret: 3
read() ret: 3
hi
pipe2.cSuccessNone
pipe2() ret: [3, 4]
write() ret: 3
read() ret: 3
hi
pipeinput.cFailureLind_wasm_Timeout
Timed Out (timeout: 10s)
pipeinput2.cSuccessNone
about to write to pipe in parent
I'm parent with pid: 2
Hey Nick!

pipeonestring.cSuccessNone
about to write to pipe in parent
I'm child with pid: 0
I'm parent with pid: 2
Hey Nick!
������
pipewrite.cSuccessNone
Made pipe with write end 3 and read end 4
wrote 16
write 16
wrote 16
wrote three messages to the pipe
msg 0, length 16: hello, world #1
msg 1, length 16: hello, world #2
msg 2, length 16: hello, world #3
shutdown_fork.cSuccessNone
2�8d-05
simple-select.cSuccessNone
[child] waiting for data...
[parent] writing message
[child] got data: hello select!

[child] waiting for data...
[child] pipe closed

socketepoll.cSuccessNone
SERVER: New socket bound and listen
SERVER: NEW CONNECTION
Hello from client
CLIENT: Hello message sent
Message Received
CLIENT: sending followup
Did you get my message?
CLIENT: Closed connection
Closed connection on descriptor 6
read error: Connection reset by peer
Process Tests
fork2malloc.cSuccessNone
first malloc
Address of mptr1 0x30010
Contents of mptr1 deadbeef
pre-fork
in child
Address of mptr1 0x30fc0
done
fork_simple.cSuccessNone
Parent pid = 1
Child pid = 2
forkandopen.cSuccessNone
Child: Testing open in child: pid 0!
Parent: Testing open in parent: pid 2!
Parent: Pid 2 opened fd -1
Child: Pid 0 opened fd -1
forkfiles.cSuccessNone
read -1 chars
forkmalloc.cSuccessNone
in child
pointer address is 0x30010
done
forknodup.cSuccessNone
I'm the PARENT
I'm the child
all done
all done
getpid.cSuccessNone
printing pidSuccess
Signal Tests
signal.cSuccessNone
main starts!
parent in loop, pid=1
child ready to kill
child done kill
Caught signal 10
parent in loop, pid=1
Terminated
signal_SIGCHLD.cSuccessNone
main starts!
parent in loop, pid=1
child ready to kill
child done kill
Caught signal 17
Caught signal 10
signal_fork.cSuccessNone
main starts!
parent in loop, pid=1
child ready to kill
child done kill
Caught signal 2
after fork inside signal handler, pid=3
after fork inside signal handler, pid=1
parent in loop, pid=3
parent in loop, pid=1
parent in loop, pid=3
parent in loop, pid=1
parent in loop, pid=3
parent in loop, pid=1
parent in loop, pid=3
parent in loop, pid=1
signal_int_thread.cSuccessNone
main starts!
Hello from thread
thread sleep
thread sleep
child ready to kill
child done kill
Terminated
child in loop, pid=2
Terminated
child in loop, pid=2
child in loop, pid=2
child in loop, pid=2
child in loop, pid=2
signal_longjmp.cSuccessNone
main starts!
parent in loop, pid=1
child ready to kill
child done kill
Caught signal 10
after fork inside signal handler, pid=3
after fork inside signal handler, pid=1
after child longjmp (should only be printed once by parent)
parent in loop, pid=1
back from setjmp: 42! pid=3
parent in loop, pid=1
parent in loop, pid=1
parent in loop, pid=1
signal_nodefer.cSuccessNone
main starts!
parent in loop, pid=1
*child ready to kill
*child sent SIGUSR1
*child ready to send SIGUSR1 again
Caught signal 10
start of signal handler
*child done kill
Caught signal 10
start of signal handler
end of signal handler
end of signal handler
parent in loop, pid=1
parent in loop, pid=1
parent in loop, pid=1
parent in loop, pid=1
signal_procmask.cSuccessNone
Parent: Blocking SIGINT...
Signal 2 is BLOCKED
Parent: SIGINT is blocked. Child will send SIGINT soon...
Child: Sending SIGINT to parent (PID: 1)
Parent: Unblocking SIGINT now.
SIGINT received! (Handled in Parent Process)
Signal 2 is UNBLOCKED
Parent: Waiting for SIGINT...
signal_sa_mask.cSuccessNone
main starts!
parent in loop, pid=1
child ready to kill
child done kill
Caught signal 10
signal 10 done
Caught signal 12
signal 12 done
parent in loop, pid=1
parent in loop, pid=1
parent in loop, pid=1
parent in loop, pid=1

@Yaxuan-w Yaxuan-w changed the title Refactor grate closure registration and add grate test examples Refactor grate execution path and add grate test examples Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redesign grate execution flow to use a unified entry function and indirect call dispatch

3 participants