Fail of OpenCL example on iMX8 Plus

Hey Community,

I am trying to test OpenCL example, like here: How to use OpenCL 1.2 in iMX8 on Torizon | Toradex Developer Center and instantly getting

free(): double free detected in tcache 2

Quick check in gdb shows fail in

Program received signal SIGABRT, Aborted.
0x0000007fa6e409f0 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
(gdb) bt
#0  0x0000007fa6e409f0 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
#1  0x0000007fa6dfa72c in raise () from /lib/aarch64-linux-gnu/libc.so.6
#2  0x0000007fa6de747c in abort () from /lib/aarch64-linux-gnu/libc.so.6
#3  0x0000007fa6e34aac in ?? () from /lib/aarch64-linux-gnu/libc.so.6
#4  0x0000007fa6e4ae4c in ?? () from /lib/aarch64-linux-gnu/libc.so.6
#5  0x0000007fa6e4d038 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
#6  0x0000007fa6e4f70c in free () from /lib/aarch64-linux-gnu/libc.so.6
#7  0x0000007fa6d60920 in gcoOS_FreeMemory () from /lib/aarch64-linux-gnu/libGAL.so
#8  0x0000007fa6d60990 in gcoOS_Free () from /lib/aarch64-linux-gnu/libGAL.so
#9  0x0000007fa6fa1f6c in ?? () from /lib/aarch64-linux-gnu/libOpenCL.so.1
#10 0x0000007fa6fa20e8 in clGetPlatformIDs () from /lib/aarch64-linux-gnu/libOpenCL.so.1
#11 0x0000005584b388bc in ?? ()
#12 0x0000007fa6de7740 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
#13 0x0000007fa6de7818 in __libc_start_main () from /lib/aarch64-linux-gnu/libc.so.6
#14 0x0000005584b38eb0 in ?? ()

What am I doing wrong?

tdx-info:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.6.101-7.4.0-g557af2783d91 #1-Torizon SMP PREEMPT Thu Sep 25 07:49:28 UTC 2025
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.0/torizon/070befb47d6345d681495419f0ad302a97841c839c145c94e41469b4eb2033fd/0
Distro name:              NAME="Torizon OS"
Distro version:           VERSION_ID=7.4.0-build.28
Distro variant:           VARIANT="Docker"
Hostname:                 verdin-imx8mp-15637947
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus on Verdin Development Board
Toradex version:          0063 V1.1B
Serial number:            15637947
Processor arch:           aarch64
------------------------------------------------------------

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


The double free error you’re experiencing with OpenCL on your Verdin iMX8M Plus with Torizon OS 7.4.0 suggests a memory management issue in the OpenCL implementation. Based on your setup information, you’re running on supported hardware for OpenCL 1.2(1).

Troubleshooting Steps

1. Verify Container Setup

Ensure you’re using the correct container image and device permissions. The OpenCL container requires specific device access(1):

docker run -e ACCEPT_FSL_EULA=1 -it --rm --name=clpeak-container --device /dev/galcore:/dev/galcore <your-dockerhub-username>/opencl-image

(1)

2. Check Required Prerequisites

Your Verdin iMX8M Plus is listed as supported hardware for OpenCL(1). The documentation confirms support for:

  • Toradex Apalis iMX8, Colibri iMX8X or Verdin iMX8M Plus SoM with Torizon installed(1)

3. Container Image Verification

The sample uses a two-stage build process with specific dependencies(1):

  • Build stage: Cross-compiles the clpeak application with build-time dependencies like CMake and OpenCL headers(1)
  • Deploy stage: Contains the final binary and runtime dependencies including OpenCL libraries(1)

4. Test with clinfo First

Before running complex applications, test basic OpenCL functionality with clinfo(1):

docker run -e ACCEPT_FSL_EULA=1 -it --rm --name=clpeak-container --device /dev/galcore:/dev/galcore --entrypoint=clinfo <your-dockerhub-username>/opencl-image

(1)

Potential Causes

The stack trace shows the error originates in libGAL.so during gcoOS_FreeMemory(), which suggests:

  1. Version compatibility: Torizon OS 7.4.0 may have different OpenCL library versions than what the container expects
  2. Device permissions: The /dev/galcore device may not be properly accessible
  3. Container image issues: The container may need rebuilding for your specific Torizon OS version

Next Steps

  1. Rebuild the container image from the samples repository to ensure compatibility with your Torizon OS version(1)
  2. Verify the EULA acceptance and device permissions are correctly set
  3. Test with the simpler clinfo tool before attempting clpeak

The OpenCL implementation should work on your hardware configuration, as Verdin iMX8M Plus is explicitly supported for OpenCL 1.2 applications(1).

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi @svt!

Unfortunately, this article is outdated, and we haven’t tested it for the new versions of Torizon.

That being said, we are currently working on improving and updating our documentation on IA and hardware acceleration.

Best regards.

1 Like