-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] syscall(linux): forkAndExecInChild #959
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #959 +/- ##
=======================================
Coverage 81.58% 81.58%
=======================================
Files 53 53
Lines 9050 9050
=======================================
Hits 7383 7383
Misses 1516 1516
Partials 151 151 ☔ View full report in Codecov by Sentry. |
39ecf9e
to
8dee005
Compare
53da08a
to
adde0ab
Compare
The wrapper is accurate, the reason why the function is different from Go's is that libc wraps Clone in its way. Raw Syscall may like(x86-64): long clone(unsigned long flags, void *stack,
int *parent_tid, int *child_tid,
unsigned long tls); In libc, it may like: int clone(int (*fn)(void *_Nullable), void *stack, int flags,
void *_Nullable arg, ... /* pid_t *_Nullable parent_tid,
void *_Nullable tls,
pid_t *_Nullable child_tid */ ); Acutally, the stack can be nullable, however, libc does a force verification for stack: Code from gblic ENTRY (__clone)
cmp r0, 0 /* @fn can't be NULL. */
and r1,r1,-4 /* @child_stack be 4 bytes aligned per ABI. */
cmp.ne r1, 0 /* @child_stack can't be NULL. */
bz L (__sys_err) In libc, stack cannot be nullable because of calling the fn. When you don't need to call fn, the stack param can be zero. |
Good investgation! We may use the c.syscall to call the clone function from core like go vForkSyscall , to avoid libc's wrapper check. |
08fd9c1
to
ce26637
Compare
617b4a2
to
8930624
Compare
f4cfdd0
to
230e3ea
Compare
[Git-flow] Hi @luoliwoshang, There are some suggestions for your information: Rebase suggestions
Which seems insignificant, recommend to use For other If you have any questions about this comment, feel free to raise an issue here: |
result
before use exec.command in linux
got
now
env
question
in ci, the demo will fail,but in my local docker env , can run success
https://github.com/goplus/llgo/actions/runs/12826009988/job/35765102523?pr=959
other question(resolved)
in linux, go use clone to fork a child process,current is temp use fork to create a child process
src/syscall/exec_linux.go
in above code,only pass two param to clone, but in the signature of c,have three params
and if we only pass the flags & arg through call c.clone
will got
its error output like use clone without child_stack , got Invalid argument
in the under asm code,it have some operate