From a9021cb55f98e28cfd318a36773f203842ddbf5c Mon Sep 17 00:00:00 2001 From: Peter M Date: Fri, 27 Dec 2024 21:58:07 +0100 Subject: [PATCH 1/9] Chore: Bump esp-idf Use 5.3.2 for releases. Signed-off-by: Peter M --- .github/workflows/esp32-build.yaml | 8 ++++---- .github/workflows/esp32-mkimage.yaml | 2 +- doc/release-notes.md.in | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/esp32-build.yaml b/.github/workflows/esp32-build.yaml index 741ae9e4d..dd036776a 100644 --- a/.github/workflows/esp32-build.yaml +++ b/.github/workflows/esp32-build.yaml @@ -39,15 +39,15 @@ jobs: esp-idf-target: ["esp32", "esp32c3"] idf-version: - 'v5.0.7' - - 'v5.1.4' - - 'v5.2.2' - - 'v5.3.1' + - 'v5.1.5' + - 'v5.2.3' + - 'v5.3.2' exclude: - esp-idf-target: "esp32c3" idf-version: 'v5.0.7' - esp-idf-target: "esp32c3" - idf-version: 'v5.1.4' + idf-version: 'v5.1.5' steps: - name: Checkout repo uses: actions/checkout@v4 diff --git a/.github/workflows/esp32-mkimage.yaml b/.github/workflows/esp32-mkimage.yaml index 001a15d69..4e16fc1a7 100644 --- a/.github/workflows/esp32-mkimage.yaml +++ b/.github/workflows/esp32-mkimage.yaml @@ -37,7 +37,7 @@ jobs: strategy: matrix: - idf-version: ["5.3.1"] + idf-version: ["5.3.2"] cc: ["clang-14"] cxx: ["clang++-14"] cflags: ["-O3"] diff --git a/doc/release-notes.md.in b/doc/release-notes.md.in index f3f46540d..382c71f25 100644 --- a/doc/release-notes.md.in +++ b/doc/release-notes.md.in @@ -68,9 +68,9 @@ AtomVM currently supports the following versions of ESP-IDF: | IDF SDK supported versions | AtomVM support | |------------------------------|----------------| | ESP-IDF [v5.0](https://docs.espressif.com/projects/esp-idf/en/v5.0.7/esp32/get-started/index.html) | ✅ | -| ESP-IDF [v5.1](https://docs.espressif.com/projects/esp-idf/en/v5.1.4/esp32/get-started/index.html) | ✅ | -| ESP-IDF [v5.2](https://docs.espressif.com/projects/esp-idf/en/v5.2.2/esp32/get-started/index.html) | ✅ | -| ESP-IDF [v5.3](https://docs.espressif.com/projects/esp-idf/en/v5.3/esp32/get-started/index.html) | ✅ | +| ESP-IDF [v5.1](https://docs.espressif.com/projects/esp-idf/en/v5.1.5/esp32/get-started/index.html) | ✅ | +| ESP-IDF [v5.2](https://docs.espressif.com/projects/esp-idf/en/v5.2.3/esp32/get-started/index.html) | ✅ | +| ESP-IDF [v5.3](https://docs.espressif.com/projects/esp-idf/en/v5.3.2/esp32/get-started/index.html) | ✅ | Building the AtomVM virtual machine for ESP32 is optional. In most cases, you can simply download a release image from the AtomVM [release](https://github.com/atomvm/AtomVM/releases) repository. If you wish to work on development of the VM or use one on the additional drivers that are available in the [AtomVM repositories](https://github.com/atomvm) you will to build AtomVM from source. See the [Build Instructions](build-instructions.md) for information about how to build AtomVM from source code. We recommend you to use the latest subminor (patch) versions for source builds. You can check the current version used for testing in the [esp32-build.yaml](https://github.com/atomvm/AtomVM/actions/workflows/esp32-build.yaml) workflow. From 96d9cf5d92065f2cd05c459d9da4ae214919aa74 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Sat, 28 Dec 2024 11:56:47 +0100 Subject: [PATCH 2/9] CI: Update CodeQL action before deprecation Use v3 before v2 is deprecated, also explicitly set ubuntu version to 24.04 so we can switch in advance and test it. Signed-off-by: Davide Bettio --- .github/workflows/codeql-analysis.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index f8e9ae190..8dc9d48e4 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -39,7 +39,7 @@ concurrency: jobs: analyze: name: Analyze - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 permissions: actions: read contents: read @@ -61,7 +61,7 @@ jobs: uses: actions/checkout@v4 - name: "Initialize CodeQL" - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} queries: +./code-queries/term-to-non-term-func.ql,./code-queries/non-term-to-term-func.ql @@ -74,4 +74,4 @@ jobs: ninja - name: "Perform CodeQL Analysis" - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 From b9f79d760e99a0b677a4708f5aca1e2f2c70a3fd Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Sat, 28 Dec 2024 12:16:20 +0100 Subject: [PATCH 3/9] CI: use ubuntu-24.04 instead of ubuntu-latest Using ubuntu-24.04 allows us to start testing it in advance and to decide when making any future change. Signed-off-by: Davide Bettio --- .github/workflows/esp32-build.yaml | 2 +- .github/workflows/reuse-lint.yaml | 2 +- .github/workflows/wasm-build.yaml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/esp32-build.yaml b/.github/workflows/esp32-build.yaml index dd036776a..86ded3b56 100644 --- a/.github/workflows/esp32-build.yaml +++ b/.github/workflows/esp32-build.yaml @@ -29,7 +29,7 @@ concurrency: jobs: esp-idf: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: espressif/idf:${{ matrix.idf-version }} strategy: diff --git a/.github/workflows/reuse-lint.yaml b/.github/workflows/reuse-lint.yaml index ed63ea86a..cf5e72a31 100644 --- a/.github/workflows/reuse-lint.yaml +++ b/.github/workflows/reuse-lint.yaml @@ -12,7 +12,7 @@ concurrency: jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: REUSE Compliance Check diff --git a/.github/workflows/wasm-build.yaml b/.github/workflows/wasm-build.yaml index 8de03e7f1..4a67d5316 100644 --- a/.github/workflows/wasm-build.yaml +++ b/.github/workflows/wasm-build.yaml @@ -78,7 +78,7 @@ jobs: wasm_build_and_test_node: needs: compile_tests - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: emscripten/emsdk steps: - name: Checkout repo @@ -145,7 +145,7 @@ jobs: src/platforms/emscripten/build/src/AtomVM-node-${{ github.ref_name }}.wasm.sha256 wasm_build_web: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: emscripten/emsdk steps: - name: Checkout repo @@ -175,7 +175,7 @@ jobs: wasm_test_web: needs: [compile_tests, wasm_build_web] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout repo uses: actions/checkout@v4 From bb2f067265a1ed1131a5e1c5b17a8157b392cf01 Mon Sep 17 00:00:00 2001 From: Peter M Date: Sun, 29 Dec 2024 12:32:48 +0100 Subject: [PATCH 4/9] Test esp-idf v5.4-rc1 in sim_test Future proof logic around esp32p4/h2, so they are expanded for a full_sim_test. Signed-off-by: Peter M --- .github/workflows/esp32-simtest.yaml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/esp32-simtest.yaml b/.github/workflows/esp32-simtest.yaml index 0c04c3c6e..cb5d1f74a 100644 --- a/.github/workflows/esp32-simtest.yaml +++ b/.github/workflows/esp32-simtest.yaml @@ -59,13 +59,26 @@ jobs: fail-fast: false # focus on device diversity. matrix: - esp-idf-target: ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6"] - idf-version: ${{ ((contains(github.event.head_commit.message, 'full_sim_test')||contains(github.event.pull_request.title, 'full_sim_test')) && fromJSON('["v5.1.5", "v5.2.3", "v5.3.2", "v5.4-beta1"]')) || fromJSON('["v5.3.2"]') }} - include: + esp-idf-target: + [ + "esp32", + "esp32s2", + "esp32s3", + "esp32c3", + "esp32c6", + "esp32h2", + "esp32p4", + ] + idf-version: ${{ ((contains(github.event.head_commit.message, 'full_sim_test')||contains(github.event.pull_request.title, 'full_sim_test')) && fromJSON('["v5.1.5", "v5.2.3", "v5.3.2", "v5.4-rc1"]')) || fromJSON('["v5.3.2"]') }} + exclude: - esp-idf-target: "esp32p4" - idf-version: "v5.3.2" + idf-version: "v5.1.5" + - esp-idf-target: "esp32p4" + idf-version: "v5.2.3" + - esp-idf-target: "esp32h2" + idf-version: "v5.1.5" - esp-idf-target: "esp32h2" - idf-version: "v5.3.2" + idf-version: "v5.2.3" steps: - name: Checkout repo From f7592e23a1c8938dcc7cfc388275cb3a34d33c7d Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Fri, 3 Jan 2025 19:09:18 +0100 Subject: [PATCH 5/9] Add workaround for latest debian gcc-arm-none-eabi Fixes #1445 Signed-off-by: Paul Guyot --- .github/workflows/pico-build.yaml | 2 +- .github/workflows/stm32-build.yaml | 13 +------------ CHANGELOG.md | 1 + src/libAtomVM/term.h | 3 +++ 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pico-build.yaml b/.github/workflows/pico-build.yaml index 0d1fec96b..25c8d516c 100644 --- a/.github/workflows/pico-build.yaml +++ b/.github/workflows/pico-build.yaml @@ -33,7 +33,7 @@ concurrency: jobs: pico: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: board: ["pico", "pico_w"] diff --git a/.github/workflows/stm32-build.yaml b/.github/workflows/stm32-build.yaml index b33fcccb0..feacf4985 100644 --- a/.github/workflows/stm32-build.yaml +++ b/.github/workflows/stm32-build.yaml @@ -44,17 +44,6 @@ jobs: https://repo.hex.pm https://cdn.jsdelivr.net/hex - - name: Install arm-embedded toolchain - if: ${{ steps.builddeps-cache.outputs.cache-hit != 'true' }} - working-directory: /home/runner - run: | - set -euo pipefail - cd /home/runner - wget https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz \ - --output-document=$RUNNER_TEMP/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz - tar xJf $RUNNER_TEMP/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz - pwd && ls - - name: Checkout and build libopencm3 if: ${{ steps.builddeps-cache.outputs.cache-hit != 'true' }} working-directory: /home/runner @@ -71,7 +60,7 @@ jobs: run: sudo apt update - name: "Install deps" - run: sudo apt install -y cmake gperf + run: sudo apt install -y cmake gperf gcc-arm-none-eabi - name: Checkout repo uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b7d8d9c..55e71914a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ certain VM instructions are used. - Fixed an issue where a timeout would occur immediately in a race condition - Fixed SPI close command - Added missing lock on socket structure +- Fixed compilation with latest debian gcc-arm-none-eabi ## [0.6.5] - 2024-10-15 diff --git a/src/libAtomVM/term.h b/src/libAtomVM/term.h index f926ef6d5..cecad50c5 100644 --- a/src/libAtomVM/term.h +++ b/src/libAtomVM/term.h @@ -28,6 +28,9 @@ #ifndef _TERM_H_ #define _TERM_H_ +// gcc-arm-none-eabi 13.2.1 with newlib requires this first +#include + #include #include #include From af808361c5025e761d5dc635149e7e5f88c8ed25 Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Thu, 2 Jan 2025 20:24:06 +0100 Subject: [PATCH 6/9] Fix double free of esp32 uart driver on close - Also fix usage of memory_ensure_free in esp32 uart driver - Also remove unnecessary condition in context_destroy Signed-off-by: Paul Guyot --- CHANGELOG.md | 1 + src/libAtomVM/context.c | 4 +--- .../esp32/components/avm_builtins/uart_driver.c | 9 +++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b7d8d9c..091339644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ certain VM instructions are used. - Fixed an issue where a timeout would occur immediately in a race condition - Fixed SPI close command - Added missing lock on socket structure +- Fixed a double free when esp32 uart driver was closed, yielding an assert abort ## [0.6.5] - 2024-10-15 diff --git a/src/libAtomVM/context.c b/src/libAtomVM/context.c index 46cff747e..1fd22be10 100644 --- a/src/libAtomVM/context.c +++ b/src/libAtomVM/context.c @@ -178,9 +178,7 @@ void context_destroy(Context *ctx) // globalcontext_get_process_lock before accessing platform_data. // Here, the context can no longer be acquired with // globalcontext_get_process_lock, so it's safe to free the pointer. - if (ctx->platform_data) { - free(ctx->platform_data); - } + free(ctx->platform_data); free(ctx); } diff --git a/src/platforms/esp32/components/avm_builtins/uart_driver.c b/src/platforms/esp32/components/avm_builtins/uart_driver.c index 22f9ed398..8f141d77b 100644 --- a/src/platforms/esp32/components/avm_builtins/uart_driver.c +++ b/src/platforms/esp32/components/avm_builtins/uart_driver.c @@ -309,7 +309,7 @@ static void uart_driver_do_read(Context *ctx, GenMessage gen_message) int local_pid = term_to_local_process_id(pid); if (uart_data->reader_process_pid != term_invalid_term()) { - if (UNLIKELY(memory_ensure_free(ctx, TUPLE_SIZE(2) * 2 + REF_SIZE) != MEMORY_GC_OK)) { + if (UNLIKELY(memory_ensure_free_with_roots(ctx, TUPLE_SIZE(2) * 2 , 1, &ref, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) { ESP_LOGE(TAG, "[uart_driver_do_read] Failed to allocate space for error tuple"); globalcontext_send_message(glb, local_pid, MEMORY_ATOM); return; @@ -326,7 +326,7 @@ static void uart_driver_do_read(Context *ctx, GenMessage gen_message) if (count > 0) { int bin_size = term_binary_heap_size(count); - if (UNLIKELY(memory_ensure_free(ctx, bin_size + TUPLE_SIZE(2) * 2 + REF_SIZE) != MEMORY_GC_OK)) { + if (UNLIKELY(memory_ensure_free_with_roots(ctx, bin_size + TUPLE_SIZE(2) * 2, 1, &ref, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) { ESP_LOGE(TAG, "[uart_driver_do_read] Failed to allocate space for return value"); globalcontext_send_message(glb, local_pid, MEMORY_ATOM); } @@ -387,7 +387,7 @@ static void uart_driver_do_write(Context *ctx, GenMessage gen_message) free(buffer); int local_pid = term_to_local_process_id(pid); - if (UNLIKELY(memory_ensure_free(ctx, TUPLE_SIZE(2) + REF_SIZE) != MEMORY_GC_OK)) { + if (UNLIKELY(memory_ensure_free_with_roots(ctx, TUPLE_SIZE(2), 1, &ref, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) { ESP_LOGE(TAG, "[uart_driver_do_write] Failed to allocate space for return value"); globalcontext_send_message(glb, local_pid, MEMORY_ATOM); } @@ -406,7 +406,7 @@ static void uart_driver_do_close(Context *ctx, GenMessage gen_message) sys_unregister_listener(glb, &uart_data->listener); - if (UNLIKELY(memory_ensure_free(ctx, TUPLE_SIZE(2) + REF_SIZE) != MEMORY_GC_OK)) { + if (UNLIKELY(memory_ensure_free_with_roots(ctx, TUPLE_SIZE(2), 1, &ref, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) { ESP_LOGE(TAG, "[uart_driver_do_close] Failed to allocate space for return value"); globalcontext_send_message(glb, local_pid, MEMORY_ATOM); } @@ -419,6 +419,7 @@ static void uart_driver_do_close(Context *ctx, GenMessage gen_message) } free(uart_data); + ctx->platform_data = NULL; } static NativeHandlerResult uart_driver_consume_mailbox(Context *ctx) From 46cde9838d284472a5585b99c63cd9fdacbadf7d Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Sun, 5 Jan 2025 11:28:15 +0100 Subject: [PATCH 7/9] Fix dubious logic revealed by esp idf 5.4 warning Signed-off-by: Paul Guyot --- src/platforms/esp32/components/avm_sys/sys.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/platforms/esp32/components/avm_sys/sys.c b/src/platforms/esp32/components/avm_sys/sys.c index acb6b173d..1581cb83d 100644 --- a/src/platforms/esp32/components/avm_sys/sys.c +++ b/src/platforms/esp32/components/avm_sys/sys.c @@ -677,12 +677,12 @@ static void *select_thread_loop(void *arg) { GlobalContext *glb = arg; struct ESP32PlatformData *platform = glb->platform_data; - struct pollfd *fds = malloc(0); + struct pollfd *fds = NULL; while (!platform->select_thread_exit) { int select_events_poll_count = platform->select_events_poll_count; int poll_count = 1; int fd_index; - if (select_events_poll_count < 0) { + if (fds == NULL || select_events_poll_count < 0) { // Means it is dirty and should be rebuilt. struct ListHead *select_events = synclist_wrlock(&glb->select_events); size_t select_events_new_count; @@ -692,7 +692,11 @@ static void *select_thread_loop(void *arg) select_events_new_count = select_events_poll_count; } - fds = realloc(fds, sizeof(struct pollfd) * (poll_count + select_events_new_count)); + if (fds) { + fds = realloc(fds, sizeof(struct pollfd) * (poll_count + select_events_new_count)); + } else { + fds = malloc(sizeof(struct pollfd) * (poll_count + select_events_new_count)); + } fds[0].fd = platform->signal_fd; fds[0].events = POLLIN; From e487ea71c97e1eabe6b47ffa3cb1bbfe303577da Mon Sep 17 00:00:00 2001 From: Winford Date: Sun, 5 Jan 2025 08:06:42 +0000 Subject: [PATCH 8/9] Add ESP-IDF v5.4 (official) to workflows and supported build environment in relase notes. Bumps version the esp32-build.yaml, and esp32-simtest.yaml for runs that include a full_sim_test to ESP-IDF v5.4. Adds ESP-IDF v5.4 to supported build environments in the release-0.6 release notes. Signed-off-by: Winford --- .github/workflows/esp32-build.yaml | 1 + .github/workflows/esp32-simtest.yaml | 2 +- doc/release-notes.md.in | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/esp32-build.yaml b/.github/workflows/esp32-build.yaml index 86ded3b56..1c2b3ab0d 100644 --- a/.github/workflows/esp32-build.yaml +++ b/.github/workflows/esp32-build.yaml @@ -42,6 +42,7 @@ jobs: - 'v5.1.5' - 'v5.2.3' - 'v5.3.2' + - 'v5.4' exclude: - esp-idf-target: "esp32c3" diff --git a/.github/workflows/esp32-simtest.yaml b/.github/workflows/esp32-simtest.yaml index cb5d1f74a..55177a47e 100644 --- a/.github/workflows/esp32-simtest.yaml +++ b/.github/workflows/esp32-simtest.yaml @@ -69,7 +69,7 @@ jobs: "esp32h2", "esp32p4", ] - idf-version: ${{ ((contains(github.event.head_commit.message, 'full_sim_test')||contains(github.event.pull_request.title, 'full_sim_test')) && fromJSON('["v5.1.5", "v5.2.3", "v5.3.2", "v5.4-rc1"]')) || fromJSON('["v5.3.2"]') }} + idf-version: ${{ ((contains(github.event.head_commit.message, 'full_sim_test')||contains(github.event.pull_request.title, 'full_sim_test')) && fromJSON('["v5.1.5", "v5.2.3", "v5.3.2", "v5.4"]')) || fromJSON('["v5.3.2"]') }} exclude: - esp-idf-target: "esp32p4" idf-version: "v5.1.5" diff --git a/doc/release-notes.md.in b/doc/release-notes.md.in index 382c71f25..1de96f072 100644 --- a/doc/release-notes.md.in +++ b/doc/release-notes.md.in @@ -71,6 +71,7 @@ AtomVM currently supports the following versions of ESP-IDF: | ESP-IDF [v5.1](https://docs.espressif.com/projects/esp-idf/en/v5.1.5/esp32/get-started/index.html) | ✅ | | ESP-IDF [v5.2](https://docs.espressif.com/projects/esp-idf/en/v5.2.3/esp32/get-started/index.html) | ✅ | | ESP-IDF [v5.3](https://docs.espressif.com/projects/esp-idf/en/v5.3.2/esp32/get-started/index.html) | ✅ | +| ESP-IDF [v5.4](https://docs.espressif.com/projects/esp-idf/en/v5.4/esp32/get-started/index.html) | ✅ | Building the AtomVM virtual machine for ESP32 is optional. In most cases, you can simply download a release image from the AtomVM [release](https://github.com/atomvm/AtomVM/releases) repository. If you wish to work on development of the VM or use one on the additional drivers that are available in the [AtomVM repositories](https://github.com/atomvm) you will to build AtomVM from source. See the [Build Instructions](build-instructions.md) for information about how to build AtomVM from source code. We recommend you to use the latest subminor (patch) versions for source builds. You can check the current version used for testing in the [esp32-build.yaml](https://github.com/atomvm/AtomVM/actions/workflows/esp32-build.yaml) workflow. From 777a1ba98394dff291722fabd5ae5e31d8829d09 Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Mon, 6 Jan 2025 22:37:52 +0100 Subject: [PATCH 9/9] Fix race condition in timeout handling Signed-off-by: Paul Guyot --- CHANGELOG.md | 1 + src/libAtomVM/scheduler.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b7d8d9c..af2dfba82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ certain VM instructions are used. - Fixed an issue where a timeout would occur immediately in a race condition - Fixed SPI close command - Added missing lock on socket structure +- Fixed a race condition affecting multi-core MCUs where a timeout would not be properly cleared ## [0.6.5] - 2024-10-15 diff --git a/src/libAtomVM/scheduler.c b/src/libAtomVM/scheduler.c index 21f1d7d75..ce97bbb16 100644 --- a/src/libAtomVM/scheduler.c +++ b/src/libAtomVM/scheduler.c @@ -414,11 +414,11 @@ void scheduler_cancel_timeout(Context *ctx) { GlobalContext *glb = ctx->global; - context_update_flags(ctx, ~(WaitingTimeout | WaitingTimeoutExpired), NoFlags); - struct TimerList *tw = &glb->timer_list; SMP_SPINLOCK_LOCK(&glb->timer_spinlock); timer_list_remove(tw, &ctx->timer_list_head); SMP_SPINLOCK_UNLOCK(&glb->timer_spinlock); + + context_update_flags(ctx, ~(WaitingTimeout | WaitingTimeoutExpired), NoFlags); }