From ea408669fbd25717cdd97aeaded79e4b47d12e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 29 Jul 2025 10:04:32 +0200 Subject: [PATCH 1/2] Fix evaluation crashing when group leader is from another node --- c_src/pythonx.cpp | 12 +++++++----- mix.exs | 2 +- mix.lock | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/c_src/pythonx.cpp b/c_src/pythonx.cpp index 11f12bf..f694e71 100644 --- a/c_src/pythonx.cpp +++ b/c_src/pythonx.cpp @@ -190,7 +190,8 @@ struct ExObject { static constexpr auto module = &atoms::ElixirPythonxObject; static constexpr auto fields() { - return std::make_tuple(std::make_tuple(&ExObject::resource, &atoms::resource)); + return std::make_tuple( + std::make_tuple(&ExObject::resource, &atoms::resource)); } }; @@ -216,8 +217,8 @@ struct ExError { }; struct EvalInfo { - ErlNifPid stdout_device; - ErlNifPid stderr_device; + fine::Term stdout_device; + fine::Term stderr_device; ErlNifEnv *env; std::thread::id thread_id; }; @@ -1140,7 +1141,7 @@ std::tuple compile(ErlNifEnv *env, std::tuple, fine::Term> eval(ErlNifEnv *env, ErlNifBinary code, std::string code_md5, std::vector> globals, - ErlNifPid stdout_device, ErlNifPid stderr_device) { + fine::Term stdout_device, fine::Term stderr_device) { ensure_initialized(); // Step 1: compile (or get cached result) @@ -1388,7 +1389,8 @@ extern "C" void pythonx_handle_io_write(const char *message, // Note that we send the output to Pythonx.Janitor and it then sends // it to the device. We do this to avoid IO replies being sent to - // the calling Elixir process (which would be unexpected). + // the calling Elixir process (which would be unexpected). Additionally, + // we cannot send to remote PIDs from a NIF, while the Janitor can. auto janitor_name = fine::encode(env, pythonx::atoms::ElixirPythonxJanitor); ErlNifPid janitor_pid; if (enif_whereis_pid(caller_env, janitor_name, &janitor_pid)) { diff --git a/mix.exs b/mix.exs index 743c4f9..d1f4c8b 100644 --- a/mix.exs +++ b/mix.exs @@ -39,7 +39,7 @@ defmodule Pythonx.MixProject do defp deps do [ - {:fine, "~> 0.1.0", runtime: false}, + {:fine, "~> 0.1.2", runtime: false}, {:elixir_make, "~> 0.9", runtime: false}, {:cc_precompiler, "~> 0.1", runtime: false}, {:ex_doc, "~> 0.36", only: :dev, runtime: false} diff --git a/mix.lock b/mix.lock index c0cface..fb04431 100644 --- a/mix.lock +++ b/mix.lock @@ -3,7 +3,7 @@ "earmark_parser": {:hex, :earmark_parser, "1.4.42", "f23d856f41919f17cd06a493923a722d87a2d684f143a1e663c04a2b93100682", [:mix], [], "hexpm", "6915b6ca369b5f7346636a2f41c6a6d78b5af419d61a611079189233358b8b8b"}, "elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"}, "ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"}, - "fine": {:hex, :fine, "0.1.0", "9bb99a5ff9b968f12c3b458fa1277c39e9a620b23a9439103703a25917293871", [:mix], [], "hexpm", "1d6485bf811b95dc6ae3d197c0e6f994880b86167a827983bb29cbfc03a02684"}, + "fine": {:hex, :fine, "0.1.2", "85cf7dd190c7c6c54c2840754ae977c9acc0417316255b674fad9f2678e4ecc7", [:mix], [], "hexpm", "9113531982c2b60dbea6c7233917ddf16806947cd7104b5d03011bf436ca3072"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, From e3cdadbe54a7bc50625a6f895790feeba8c1609c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 29 Jul 2025 10:11:45 +0200 Subject: [PATCH 2/2] Bump Elixir version on CI --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f0615ef..10f25a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,13 +14,13 @@ jobs: include: - pair: { elixir: "1.15.8", otp: "25.3" } python_minor: "10" - - pair: { elixir: "1.18.1", otp: "27.2" } + - pair: { elixir: "1.18.4", otp: "27.2" } python_minor: "10" - - pair: { elixir: "1.18.1", otp: "27.2" } + - pair: { elixir: "1.18.4", otp: "27.2" } python_minor: "11" - - pair: { elixir: "1.18.1", otp: "27.2" } + - pair: { elixir: "1.18.4", otp: "27.2" } python_minor: "12" - - pair: { elixir: "1.18.1", otp: "27.2" } + - pair: { elixir: "1.18.4", otp: "27.2" } python_minor: "13" lint: true env: @@ -59,7 +59,7 @@ jobs: include: - pair: { elixir: "1.15.8", otp: "25.3" } python_minor: "10" - - pair: { elixir: "1.18.1", otp: "27.2" } + - pair: { elixir: "1.18.4", otp: "27.2" } python_minor: "13" env: MIX_ENV: test @@ -92,7 +92,7 @@ jobs: include: - pair: { elixir: "1.15.8", otp: "25.3" } python_minor: "10" - - pair: { elixir: "1.18.1", otp: "27.2" } + - pair: { elixir: "1.18.4", otp: "27.2" } python_minor: "13" env: MIX_ENV: test