BUG: After malloc(AVAILABLE_HEAP), which returns 0, every malloc, even malloc(0) returns ENOMEM.

Piotr Jedyk jedaj.art@gmail.com
Tue Sep 20 17:43:00 GMT 2016


Hello!

I think, I have found a bug which cause malloc() to not work, even
malloc(0) without any successful malloc() before, so the heap should
be empty.

Description is available here:
http://stackoverflow.com/questions/39088598/malloc-in-newlib-does-it-waste-memory-after-one-big-failure-allocation

Library was built on x86_64 Debian configured as follows:
  CFLAGS_FOR_TARGET='-g3 -O0' \
  ../configure \
      --prefix="$g_tc_install" \
      --target="$g_tc_target" \
      --disable-newlib-supplied-syscalls \
      --with-gmp="$g_tc_install" \
      --with-mpfr="$g_tc_install" \
      --with-mpc="$g_tc_install" \
      --with-isl="$g_tc_install" \
    ;

Compiled with the bootstraped GCC configured as follows:
  LIBGCC2_FLAGS='-g3 -O0' \
  ../configure \
      --prefix="$g_tc_install" \
      --target="$g_tc_target" \
      --enable-languages='c,c++' \
      --enable-__cxa_atexit \
      --with-cpu="$g_tc_cpu" \
      --with-mode="$g_tc_arm_mode" \
      --with-newlib \
      --with-headers="$g_tc_build/newlib/newlib/libc/include" \
      --with-gmp="$g_tc_install" \
      --with-mpfr="$g_tc_install" \
      --with-mpc="$g_tc_install" \
      --with-isl="$g_tc_install" \
    ;

Non-path variables was:
  export g_tc_target='arm-none-eabi'
  export g_tc_cpu='cortex-m7'
  export g_tc_arm_mode='thumb'

Version was newlib-2.4.0.20160527, downloaded as a tar.



More information about the Newlib mailing list