-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std::fs file not found code: 38, message: "Function not implemented" #41347
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
Comments
Please run the code under strace. |
I will try to run strace. Yesterday I found out rust code returned file was not found. |
|
The strace is for a different error than in the original report. Please run the same code as in the original report. |
rust code without c or libc
|
Sorry over the last days I had many many attempts, I lost track. Bellow is src: use std::fs::File;
use std::str;
use std::io::BufReader;
use std::io::prelude::*;
fn main() {
use std::error::Error;
use std::path::Path;
let path = Path::new("/var/log/vmkernel.log");
let display = path.display();
// Open the path in read-only mode, returns `io::Result<File>`i
let mut file = match File::open(&path) {
// The `description` method of `io::Error` returns a string that
// describes the error
Err(why) => panic!("couldn't open {}: {} {:?}", display,
why.description(),
why.cause(),),
Ok(file) => file,
};
// Read the file contents into a string, returns `io::Result<usize>`
let mut s = String::new();
match file.read_to_string(&mut s) {
Err(why) => panic!("couldn't read {}: {}", display,
why.description()),
Ok(_) => print!("{} contains:\n{}", display, s),
} |
Here we go, that’s what your hypervisor does not implement. |
The reason why this fails only in rust is due to use of ioctl? Rust use ioctl and libc and c dosn't? is there a way to workaround it without libc or c? |
The most correct solution would be to not run executables compiled for |
can you please point me to an example or a doc? |
The targets are here. You’ll need to "fix" the libstd so incompatibilities like the one reported here are gone as well. |
@yoni386 You can't use a single ` to wrap several lines of code, you need 3 (```) on a line before (with optionally the language just after it, like rust or c) and another 3 on a line after. |
aarch64-apple-ios |
eddyb this is the return output of strace tool. |
First let me answer your bullet points:
You’ll probably want to implement a custom target such as
Pointing to a different runtime happens by selecting a suiting target:
Here I’ll describe what the fix is likely to end up looking like (bear in mind, this is a proper fix, and therefore is not easy):
Alternative approaches could be:
|
Thank you for details and for your time.
libc is not using (calling) the same functions? In c and libc I also open
fd isn't usuing ioctl? in this case isn't that better to read fd in libc as
unsafe and do all the other code which does work in rust? hypervisor isn't
a open src. esx is like "black box" i think I prefer use libc or c.
making another target is less good
…On Tue, Apr 18, 2017 at 10:52 PM, Simonas Kazlauskas < ***@***.***> wrote:
@yoni386 <https://github.com/yoni386>
First let me answer your bullet points:
except android which target is not "unknown"? (full list on the bottom).
unknown here is irrelevant and can be mostly ignored.
any idea which target can best fit to esxi?
You’ll probably want to implement a custom target such as
x86_64-esxi-linux-musl or some such.
As I know, not like in c there is no way to point to different libc,
right? how static compile?
Pointing to a different runtime happens by selecting a suiting target:
*-musl for MUSL libc, *-gnu for GNU libc, etc. The libc used is
irrelevant to your problem however, because the functionality missing is
not missing in libc, but in the kernel/platform/hypervisor itself.
by "fix" the libstd so incompatibilities like the one reported here are
gone as well. you mean modify std src code?
Here I’ll describe what the fix is likely to end up looking like (bear in
mind, this is a proper fix, and therefore is not easy):
1. You copy the most-matching target (so, probably
x86_64-unknown-linux-musl) and name it x86_64-esxi-linux-musl. Adjust
the target as necessary to make it match the particularities of the
platform;
2. change the libstd, libcore, liblibc and other libraries to support
your new target. That would indeed mean having to change the src code for
these libraries. At this point you should have a compiler that can produce
correct executables for your platform;
3. (*Optionally*) submit a PR with all these changes against upstream.
This may or may not get accepted.
Alternative approaches could be:
1. Fix the hypervisor (probably much better solution overall);
2. Stub the system call out, so it does not fail, but also does
nothing;
3. Submit a PR against libstd which makes libstd ignore the failures
from the relevant ioctl call.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41347 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALrs2rYQt5iXIZI-E6cG-_ZT8sskllf0ks5rxRR1gaJpZM4M_lXb>
.
--
Best Regards,
Yoni Shperling
--
Best Regards,
Yoni Shperling
|
@yoni386 For what it's worth, this is what that flag does:
This should be the default behavior but "worse is better". You can see cases in which this flag is set. |
how to do this?
set the close-on-exec flag (File IOctl CLose on EXec).
Setting this flag causes the file descriptor to be closed
when the calling process executes a new program
and this?
This should be the default behavior but "worse is better". You can see
cases in which this flag is set
<https://github.com/rust-lang/rust/blob/a559452b05c20041a27f518d262573c56b876b64/src/libstd/sys/unix/fd.rs#L128-L132>.
That would suggest x86_64-unknown-linux-newlib might work better but
I'm not sure it's supported.
…On Wed, Apr 19, 2017 at 1:19 PM, Eduard-Mihai Burtescu < ***@***.***> wrote:
@yoni386 <https://github.com/yoni386> For what it's worth, this is what
that flag does:
Set the close-on-exec flag (File IOctl CLose on EXec).
Setting this flag causes the file descriptor to be closed
when the calling process executes a new program.
This should be the default behavior but "worse is better". You can see cases
in which this flag is set
<https://github.com/rust-lang/rust/blob/a559452b05c20041a27f518d262573c56b876b64/src/libstd/sys/unix/fd.rs#L128-L132>
.
That would suggest x86_64-unknown-linux-newlib might work better but I'm
not sure it's supported.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41347 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALrs2spyyvrs-wrndymkOK0Hcpjpu7gbks5rxd-2gaJpZM4M_lXb>
.
--
Best Regards,
Yoni Shperling
|
@yoni386 I'm really sorry, but there seems to be a language barrier making it hard for me to help you. If you don't mind, could you tell us your native language, maybe there is someone in the Rust community who speaks it and can communicate more directly? |
Per private discussion on IRC: we think that what happens here is that ESXi sort of embeds a Linux kernel, specifically Linux 2.4, which is probably just too old to have this syscall. Does Rust target Linux 2.4? |
That would explain it. We only support kernel versions 2.6.18+.
…On Apr 19, 2017 15:35, "whitequark" ***@***.***> wrote:
Per private discussion on IRC: we think that what happens here is that
ESXi sort of embeds a Linux kernel, specifically Linux 2.4, which is
probably just too old to have this syscall.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#41347 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AApc0hFJeB9s6TP0NGMYNlyakckTG7xMks5rxf-egaJpZM4M_lXb>
.
|
|
Reading Wikipedia says ESX*i* does not use Linux kernel at all. Only the
discontinued ESX (no i) does.
…On Apr 19, 2017 15:35, "whitequark" ***@***.***> wrote:
Per private discussion on IRC: we think that what happens here is that
ESXi sort of embeds a Linux kernel, specifically Linux 2.4, which is
probably just too old to have this syscall.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#41347 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AApc0hFJeB9s6TP0NGMYNlyakckTG7xMks5rxf-egaJpZM4M_lXb>
.
|
Ah, looks like it indeed doesn't: https://www.v-front.de/2013/08/a-myth-busted-and-faq-esxi-is-not-based.html. I'm guessing then they took the easy road to compatibility by implementing Linux syscalls and then compiling busybox, etc, with musl and a Linux triple. Regardless of this the answer is the same, it needs its own target. |
Thanks everybody. I will continue to use c and c++ and maybe later I will use rust libc. |
how can I crate custom target with kernel 2.4? should I compile some how with no-std? ./rustup-init: /lib/tls/libc.so.6: version `GLIBC_2.3.4' not found (required by ./rustup-init) |
by fixed you mean? fd will not be closed but it will also not panic? or it will fallback to a valid method on 2.4? If I have more problems like that, is it possible "workaround" them? I mean in safe rust not libc or c. |
@yoni386 That patch tries the existing method but if that errors (like it does for you) it will try the other one which might work (not sure though). |
How can I check this? clone the src from github and do a manual change and compile it? |
@yoni386 You could, yeah. You can also do: git clone https://github.com/tbu-/rust
cd rust
git checkout pr_cloexec_fallback_fcntl |
We decided to hold off on the PR (#41462) at least until we could confirm that it fixes the problem here. |
Closing as we do not appear to have gotten confirmation that this fixes things and generally supporting things like this isn't really viable without help from people using those platforms. |
Rust Generated code worked on CentOS but but *fail on VMware Esxi hypervisor.
Some of the code portion does work on the same machine. explained in detail below.
c and rust libc works fine while rust std::fs panicked at 'Unable to open' "Function not implemented".
//rust libc
// c code
//the output
// full example
If it's interesting, I found more issues in rust, also in those cases I compared it to c++ which successfully worked.
Please note - in centos OS the same rust and c are working only when taking it to Esxi OS there a valid problem.
For example:
c and c++ stdout, threads, system working. in rust only stdout (prints) worked "out of the box".
As said c and c++ and libs just work "out of the box", rust from the other hand forced me to do tweaks libc and compile it static and etc. The current status:
Compiltion info:
VMware Esxi hypervisor version 6.5 with libc 2.12 (dev machine was centos 6 - compiled from cantos 6 as target x86_64-unknown-linux-musl and x86_64-unknown-linux-gnu.
target x86_64-unknown-linux-musl also from cantos7 which has libc2.17.
Let me know if more info can help. I will try more if there some kind of workaround and I will update.
The text was updated successfully, but these errors were encountered: