Skip to content

malloc poison on some compilers - cross compiling #1013

Closed
@olivierschonken

Description

Cross-compiling with buildroot, we are experiencing some pragma poisoning issues related to malloc as shown below. Most of the issues are found compiling against uclibc. malloc is poisoned in the #include "opj_includes.h" at the top of the thread file, in the uclibc threads header file, sched.h is also included, which has #defines referencing malloc. This causes the attempt to use poisoned malloc and free messages. If I move the "opj_includes.h" include to below the include <pthread.h> at line 287 and into the #ifdef MUTEX_win32 at line 37 compilation succeeds, but I'm not sure this is the best sollution.

In file included from /home/olivier/Buildroot-android-check/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sched.h:34:0,
from /home/olivier/Buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/pthread.h:24,
from /home/olivier/Buildroot/output/build/openjpeg-2.2.0/src/lib/openjp2/thread.c:288:
/home/olivier/Buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/sched.h:210:46: error: attempt to use poisoned "malloc"
 # define __sched_cpualloc(cnt) ((cpu_set_t *)malloc(__CPU_ALLOC_SIZE(cnt)))
                                              ^
/home/olivier/Buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/sched.h:211:33: error: attempt to use poisoned "free"
 # define __sched_cpufree(__set) free(__set)
                                 ^
src/lib/openjp2/CMakeFiles/openjp2_static.dir/build.make:62: recipe for target 'src/lib/openjp2/CMakeFiles/openjp2_static.dir/thread.c.o' failed
make[3]: *** [src/lib/openjp2/CMakeFiles/openjp2_static.dir/thread.c.o] Error 1
make[3]: *** Waiting for unfinished jobs....
In file included from /home/olivier/Buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sched.h:34:0,
                 from /home/olivier/Buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/pthread.h:24,
                 from /home/olivier/Buildroot/output/build/openjpeg-2.2.0/src/lib/openjp2/thread.c:288:
/home/olivier/Buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/sched.h:210:46: error: attempt to use poisoned "malloc"
 # define __sched_cpualloc(cnt) ((cpu_set_t *)malloc(__CPU_ALLOC_SIZE(cnt)))
                                              ^
/home/olivier/Buildroot-android-check/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/sched.h:211:33: error: attempt to use poisoned "free"
 # define __sched_cpufree(__set) free(__set)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions