-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Check for embedded mode in the client #8007
Conversation
CT Test Results 2 files 66 suites 1h 1m 9s ⏱️ Results for commit e0ea6f5. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
a3d8bb7
to
aad7242
Compare
lib/kernel/src/code.erl
Outdated
ensure_modules_loaded_2(OnLoad, Error1); | ||
embedded -> | ||
Error2 = [{M, {error, embedded}} || {M, _} <- OnLoad] ++ Error1, | ||
ensure_modules_loaded_2([], Error2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would just return {error, Error2}
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may not have any OnLoad
modules on partition, which means that the line above does not add new errors and we call ensure_modules_loaded_2([], [])
. :)
aad7242
to
fa59cde
Compare
d5fc3c6
to
11b050e
Compare
lib/kernel/doc/src/code.xml
Outdated
Opposite to <seemfa marker="#ensure_loaded/1">ensure_loaded/1</seemfa>, | ||
concurrent calls to this function will attempt to load | ||
modules concurrently. Furthermore, modules are loaded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If find this sentence confusing.
Does that mean that if two processes call this function "at the same time", one or more of the modules can become loaded twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more that the modules will be read and processed more than once but only loaded once. Should we replace "will attempt to load" by "will read and prepare modules concurrently, but load them once"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle there's nothing that prevents us from avoiding this multiple-load issue the same way it's avoided for ensure_loaded/1
- it's just that when I implemented this mechanism for enusre_loaded/1
the multi-load scenario was so complex I couldn't implement the change it in a reasonable way, so I decided to skip it.
11b050e
to
ad3d857
Compare
All feedback addressed. |
This ensures that checking for code:ensure_loaded/1 in embedded mode (and other operations) do not send additional messages to the code server. This pull request fully closes erlang#7889. While previous work has fixed the slow path in the code server, this pull request makes it so the code server is avoided altogether.
ad3d857
to
e0ea6f5
Compare
Rebased against master. :) |
Merged, thanks for the PR! :) |
@josevalim Using elixir 1.17.2 with OTP 27.0.1 (which should include this fix), we are encountering a similar issue and wondering if it is the same cause.
Could you point me in the right direction here? |
It seems to be a duplicate of #8510. Do you have any native dependencies (NIFs) in your application? Try calling |
I tried that but now I have a new crash:
|
The error message is "** (EXIT from #PID<0.94.0>) exited in: :gen_server.call(:elixir_config, {:serial, #Function<7.59288356/0 in System.untrap_signal/2>}, :infinity)\n ** (EXIT) no process". If it cannot find an Elixir process, it means either Erlang's stdlib/kernel or Elixir's application is shutdown, probably because something is going wrong elsewhere. It is hard to say what it is. You can try running tests with |
It does not give me any more information. I can confirm with the core dump that 0.94.0 does not exist. Interestingly (or maybe not) over multiple runs it complains about the same PID, 0.94.0. |
@josevalim I have done a little bit more digging. Here are my findings:
Here is the current_stacktrace for 0.94.0 (at the end of test):
Here is the current_stacktrace for 0.1298.0 (at the end of test):
Here is the process info for 0.94.0:
And here is the process info for 0.1298.0
Do you think you can recognise this bug? |
Adding to my helper:
Produces a slightly different error:
Everything else seems to stay the same. |
This should be fixed by #8744. |
This ensures that checking for code:ensure_loaded/1 in embedded mode (and other operations) do not send additional messages to the code server.
This pull request fully closes #7889. While previous work has fixed the slow path in the code server, this pull request makes it so the code server is avoided altogether.