-
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
Segmentation fault on OTP27 #9100
Comments
I know almost nothing about Elixir (and don't have the toolchain installed), but as this looks like a recursive function updating an accumulator represented by a tuple, it could be a fault with the destructive update of tuples optimization (new in OTP-27). If you were running plain old Erlang and compiling the module with the compiler option |
Here is the code translated to Erlang and slightly simplified:
The bug seems to be in the code for line 22. Only one of the empty binaries is created using |
Thanks Björn, I'll take a look as soon as I finish up another thing. |
@bjorng: It's an error in how a a phi-instruction with literals is patched in the destructive update pass. If more than one element of a literal tuple is patched to get its value from For now, @martosaur, compile your module with |
The code responsible for patching Phi-instructions could not handle multiple patches to a single literal value, it silently discarded all but one of the updates. This MR corrects this by merging patches, using the same mechanism as used for patching function arguments. Closes erlang#9100
While refactoring the code responsible for merging patches to different elements of a literal in function calls in order to reuse it to solve issue erlang#9100, it was discovered that it only correctly handle patches to top-level elements. If multiple elements of a tuple inside another tuple was patched, it would crash. This commit fixes the above mentioned bug and also refactors the code to separate the parts that are specific to handle function arguments from the parts that merges patches to literals. The correctness of the refactoring is tested by already existing tests. A test case verifying the fix will be added in the patch addressing erlang#9100 as is it not worthwhile to spend the time to construct a test-case testing each of the issues separately.
While refactoring the code responsible for merging patches to different elements of a literal in function calls in order to reuse it to solve issue erlang#9100, it was discovered that it only correctly handle patches to top-level elements. If multiple elements of a tuple inside another tuple was patched, it would crash. This commit fixes the above mentioned bug and also refactors the code to separate the parts that are specific to handle function arguments from the parts that merges patches to literals. The correctness of the refactoring is tested by already existing tests. A test case verifying the fix will be added in the patch addressing erlang#9100 as is it not worthwhile to spend the time to construct a test-case testing each of the issues separately.
The code responsible for patching Phi-instructions could not handle multiple patches to a single literal value, it silently discarded all but one of the updates. This MR corrects this by merging patches, using the same mechanism as used for patching function arguments. Closes erlang#9100
Describe the bug
Running this function results in a segmentation fault
To Reproduce
Run the elixir script with OTP27
Expected behavior
Function should run normally
Affected versions
Affected:
Not affected:
Additional context
Please excuse the absurd example, but this is what I could boil down the function to from the original version. Almost any part seems to be important: making
recursive
function public, matching onprev
in function head, removing unused:insert ->
clause - all fixes the issue.The text was updated successfully, but these errors were encountered: