Skip to content
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

Fix Stat Syscall #19

Open
qianxichen233 opened this issue Sep 25, 2024 · 8 comments
Open

Fix Stat Syscall #19

qianxichen233 opened this issue Sep 25, 2024 · 8 comments
Assignees

Comments

@qianxichen233
Copy link

The stat struct in glibc does not match rawposix. This causes the value assigned to stat struct in rawposix failed to update in glibc. Now all the testsuite that is using stat-related syscalls are running and will not yield any error, but the information in stat struct is incorrectly updated.
I've talked with Alice about this, and in nacl, there seems to be some kind of transformation happened in nacl runtime on stat struct to make it work. And after discussion with Nick, we decided to make the stat struct in rawposix match glibc, so no extra steps should be involved in wasmtime.

@rennergade
Copy link

We talked about this briefly at some point with @JustinCappos and I'm tagging him to clarify. The struct thats actually passed to the native kernel has a defined structure, and we want to match that. I believe the best way is to change the libc struct to match?

@JustinCappos
Copy link
Member

The stat struct in glibc does not match rawposix.

Why is this the case? Isn't glibc what is used by Rust's libc which rawposix calls?

@qianxichen233
Copy link
Author

rawposix has its own statData definition (https://github.com/Lind-Project/RawPOSIX/blob/main/src/interface/types.rs#L55)
So the stat_syscall in rawposix basically defines a libc_statbuf and pass to libc::stat, then assigns the corresponding field in libc_statbuf to rawposix statData

@Yaxuan-w
Copy link
Member

Yaxuan-w commented Sep 25, 2024

When implementing RawPOSIX, there were conflicts between NaCl stat struct and libc stat struct. I think the issue is cause by pre-allocated memory region in 32-bit NaCl doesn't fit 64-bit kernel results. To integrate NaCl, I chose to manually copy out rust libc stat result to NaCl's structure at that time

@rennergade
Copy link

When implementing RawPOSIX, there were conflicts between NaCl stat struct and libc stat struct. I think the issue is cause by pre-allocated memory region in 32-bit NaCl doesn't fit 64-bit kernel results. To integrate NaCl, I chose to manually copy out rust libc stat result to NaCl's structure at that time

Right, that makes sense. There is most likely problems with the struct layout when translating from 32 to 64 bit, hence the weird nacl layout.

@rennergade
Copy link

@robinyuan1002 this issue got fixed in the last merge, correct?

@qianxichen233
Copy link
Author

@rennergade there is still a minor issue with stat stuff when compile bash, so I guess let's leave this issue until this has been figured out

@robinyuan1002
Copy link
Collaborator

@rennergade Yes, the problem of 64bit and 32bit is solved for stat.

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

No branches or pull requests

5 participants