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(druntime): only initialize mono timers once #15009
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Thanks for your pull request, @ljmf00! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#15009" |
We have an initCount, can't e use that ? |
I think not. I see that initMonoTime initializes |
|
Whoops, of course! thanks for the correction.
Where do I find that in the spec? |
https://dlang.org/spec/const3.html#implicit_qualifier_conversions mentions how
https://dlang.org/spec/const3.html#shared_global suggests it with 'mutable':
https://dlang.org/spec/attribute.html#gshared suggests it with 'non-immutable'
I'm surprised it doesn't explicitly mention https://dlang.org/articles/migrate-to-shared.html
|
@dkorpel I don't remember the details but when we used D inside the linux kernel there was a specific case where we needed |
Found it: min 16:03 - https://www.youtube.com/watch?v=weRSwbZtKu0&t=1s&ab_channel=TheDLanguageFoundation |
Interesting, so that's on an enum: |
@ljmf00 Can you explain why this PR is needed at all? Only-once execution is already guaranteed by |
Adding the |
pragma(crt_constructor)
extern(C) void some_crt_ctor()
{
Runtime.initialize();
// ...
Runtime.terminate();
} This code can't be done twice, if the runtime was never initialized, once Line 2542 in 525d90a
|
OK, but probably the runtime code is not meant to be restarted like that anyway, i.e. more bugs besides the monotime init. Is this a solution? pragma(crt_constructor)
extern(C) void some_crt_ctor()
{
Runtime.initialize();
}
pragma(crt_destructor)
extern(C) void some_crt_dtor()
{
Runtime.terminate();
} |
And |
Right. We might clarify documentation tho:
I also understand the possibility of bogus state, since it will run the shared ctor's again, and they are meant to be run once too. |
This issue affects the usage of
Runtime.initialize()
andRuntime.terminate()
on acrt_constructor
, which, if done more than once, hangs.CC @JohanEngelen this might be useful to cherry-pick to the Weka runtime, since we rely on these routines for DPDK initialization to use traces, AFAIK. I faced this when adding some new initialization code. For future, we won't need full runtime initialization for the new tracing system, tho (theoretically, none).