-
Notifications
You must be signed in to change notification settings - Fork 327
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
Unexpected recursive calls to clock_gettime() without proper initialization #327
Comments
My guess that this is related to jemalloc (it's prominently mentioned in skynet's README). As can be seen in libfaketime's #130, this problem is known, still exists, we don't have a solution for it on libfaketime's end, and it probably cannot be fixed unless also some changes to jemalloc are made. Any fresh ideas are highly welcome. :-) |
I got this same message running
As far as I know, mssql depends on jemalloc too. |
Perhaps you could try #333? It still needs some fine-tuning, but currently this would be the way ahead regarding jemalloc compatibility. |
I tried #333's PR, adding |
I added some debug messages, it's odd because the recursive calls happen when this part is called: In this line of the PR's code: Called from here And first init time from here I'm not 100% sure, but I think that there are no other threads involved. |
Hi @wolfcw, As suggested by @ronrother, I tried to make a syscall, without any memory allocation required by dlsym(), so I started by using datefudge's code as reference because it is the same concept but way simpler than libfaketime to this little proof of concept. That's my code (it compiles) #include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <asm/unistd.h>
#include <asm/msr.h>
static long syscall_gettime(long clock, struct timespec *ts)
{
long ret;
asm("syscall" : "=a" (ret) :
"0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory");
return ret;
}
int clock_gettime(clockid_t x, struct timespec *y) {
long ret = syscall_gettime(x, y);
if (x != 0) return ret;
const long fake = -1* 10 * 365 * 24 * 60 * 60;
y->tv_sec += fake ;
return ret;
} Note that in the first call
Here a It's not stable, I still got random crashes after a couple of minutes ... it seems that SQL Server needs timestamps very badly.
Thanks a lot |
If it solves your problem, please feel free to strip anything non-essential from libfaketime to make it fit your purpose. The approach you outline may, however, be hard to turn into a more generic solution. On the one hand, libfaketime more recently also intercepts syscall(), which again just shifts the same observed problem to this function. On the other hand, syscall() is not available on all platforms that libfaketime and probably even more so jemalloc support. |
Yes, I was thinking to make a PR, but I came to this same conclusion; Maybe it's better to create a new specific tool regarding only this specific scenario (running on docker and faking time through syscall). Many thanks for your help! [EDIT] For whom it might interest: Lib dateoffset > very simple, stripped-down lib that can fake date and works with jemalloc on Linux. mssql-testing > MS SQL Server docker image with testing convenience tools, including fake dates. |
I try to run a skynet program,but something went wrong,How can I solve it?
The text was updated successfully, but these errors were encountered: