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

Fix crashes on OTP 27 by disabling ETS table compression #796

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/common/lib/elixir/features.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
defmodule Elixir.Features do
alias Lexical.VM.Versions

def with_diagnostics? do
function_exported?(Code, :with_diagnostics, 1)
end
Expand All @@ -22,4 +24,20 @@ defmodule Elixir.Features do
def contains_set_theoretic_types? do
Version.match?(System.version(), ">= 1.17.0")
end

@doc """
Whether the `:compressed` ETS table option can be safely used.

A bug in Erlang/OTP 27.0.0 and 27.0.1 can cause a segfault when
traversing the entire table with something like `:ets.foldl/3` if the
`:compressed` table option is used. When this is fixed, we can change
the version check to `"< 27.0.0 or >= 27.X"`.

Issue to track: https://github.com/erlang/otp/issues/8682
"""
def can_use_compressed_ets_table? do
%{erlang: erlang_version} = Versions.to_versions(Versions.current())

Version.match?(erlang_version, "< 27.0.0")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ defmodule Lexical.RemoteControl.Search.Store.Backends.Ets.Schemas.V3 do
end

def table_options do
[:named_table, :ordered_set, :compressed]
if Features.can_use_compressed_ets_table?() do
[:named_table, :ordered_set, :compressed]
else
[:named_table, :ordered_set]
end
end

def to_subject(charlist) when is_list(charlist), do: charlist
Expand Down
Loading