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

faketime cargo fails #402

Closed
mraszyk opened this issue Jun 27, 2022 · 10 comments
Closed

faketime cargo fails #402

mraszyk opened this issue Jun 27, 2022 · 10 comments

Comments

@mraszyk
Copy link

mraszyk commented Jun 27, 2022

faketime cannot be used with cargo (the Rust package manager):

$ cargo new hello
     Created binary (application) `hello` package
$ cd hello/
$ faketime -1minutes cargo build --release
error: process didn't exit successfully: `rustc -vV` (signal: 11, SIGSEGV: invalid memory reference)

I'm running faketime 0.9.8 on a 64-bit Ubuntu:

$ uname -a
Linux lenovo 5.15.0-40-generic #43-Ubuntu SMP Wed Jun 15 12:54:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
@wolfcw
Copy link
Owner

wolfcw commented Jun 29, 2022

I'm having a hard time reproducing this (cargo 1.42.1, rustc 1.41.1).

Any chance you could try with a more recent version of libfaketime? v0.9.8 is from 2019 and eventually there were relevant changes already.

If it still crashes, it'd be good to have some more debugging information on which system call it happened on.

@mraszyk
Copy link
Author

mraszyk commented Jun 30, 2022

Thank you for looking into this issue!

faketime v0.9.8 is what I got installed using apt install faketime on Ubuntu 22.04. After manully building and installing faketime from sources, the above command hangs. Interestingly, it does not hang when invoking cargo with faketime again after having actually built the sources without faketime:

$ faketime --version

faketime: Version 0.9.10
For usage information please use 'faketime --help'.
$ faketime -1minutes cargo build --release
^C
$ cargo build --release
   Compiling hello v0.1.0 (/home/martin/hello)
    Finished release [optimized] target(s) in 0.64s
$ faketime -1minutes cargo build --release
    Finished release [optimized] target(s) in 0.00s

and I could successfully run this faketime also on this simple example

$ cat a.cpp
#include <cstdio>
#include <ctime>

int main() {
  printf("%ld\n", time(NULL));

  return 0;
}
$ g++ -o a a.cpp
$ ./a
1656566818
$ faketime -1minutes ./a
1656566762

@wolfcw
Copy link
Owner

wolfcw commented Jun 30, 2022

Thanks for trying this out. That's already progress. :-)

Could you please tell me whether libfaketime's make test hangs as well on your system? If so, it'd be good to know your glibc version. It might then get you a step further to add FORCE_MONOTONIC_FIX to libfaketime's compile flags (in src/Makefile), and if that doesn't do the trick, additionally set the environment variable FAKETIME_DONT_FAKE_MONOTONIC to 1.

Usually hard-working maintainers per distro choose the correct compile-time parameters. I don't know why Ubuntu is still stuck to v0.9.8. Let's find out how to get it to work there, and eventually we can trigger some update process for Ubuntu then.

@mraszyk
Copy link
Author

mraszyk commented Jul 3, 2022

I could successfully execute make test without any additional setup.

@mraszyk
Copy link
Author

mraszyk commented Jul 12, 2022

Is anybody working on this issue?

@mraszyk
Copy link
Author

mraszyk commented Jul 17, 2022

Might be related to this: #130

@mraszyk
Copy link
Author

mraszyk commented Jul 17, 2022

I can confirm that this issue is due to jemalloc, building Rust from source with jemalloc = false in config.toml solves the issue. I still wonder if it was possible to link libfaketime statically so that jemalloc from Rust and malloc from libfaketime do not interfere?

@wolfcw
Copy link
Owner

wolfcw commented Jul 18, 2022

Thanks for tracing it down to jemalloc.

I recommend to find a solution that either works without libfaketime or without jemalloc. jemalloc & libfaketime is a really long-standing issue and there are no known satisfying workarounds.

If you want to dig deeper, you might want to try adding some basic error handling in the places where jemalloc calls time-related system functions. I still think the problem could be solved on jemalloc's side.

@mraszyk
Copy link
Author

mraszyk commented Jul 18, 2022

Is the issue reported with jemalloc? Anyway, for now I'll use rustc compiled without jemalloc.

@wolfcw
Copy link
Owner

wolfcw commented Jul 25, 2022

closing this as duplicate of #130 , which is still open for discussion and suggestions.

@wolfcw wolfcw closed this as completed Jul 25, 2022
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

2 participants