This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
malloc1 test and posix stdio fails
- From: Brett Delmage <Brett dot Delmage at twobikes dot ottawa dot on dot ca>
- To: ECOS mailing list <ecos-discuss at ecos dot sourceware dot org>
- Date: Tue, 16 May 2006 11:33:35 -0400 (EDT)
- Subject: [ECOS] malloc1 test and posix stdio fails
- Reply-to: Brett Delmage <Brett dot Delmage at twobikes dot ottawa dot on dot ca>
Posix stdio is not working on my May 9 CVS ARM lpcxxx target. I traced
this to malloc returning 0.
I started running through the memalloc tests. I am loading them into Flash
and running them using my JTAG debugger, as I would be with my
application. i.e. I'm not using the test driver or Redboot.
The following tests passed:
heaptest
dlmalloc1
dlmalloc2
kmemfix1
kmemvar1
However test malloc1 failed as follows:
INFO:<Starting tests from testcase
/ecos-c/usr/J1156-2/ecos-cvs-may9/ecos/packages/services/memalloc/common/current/test
s/malloc1.c for C library malloc(), calloc() and free() functions>
FAIL:<Can't determine allocation size to use>
Line: 103, File: /ecos-c/usr/J1156-2/ecos-cvs-may9/ecos/packages/services/
memalloc/common/current/tests/malloc1.c
EXIT:<done>
---------------------------------------
Which refers to the following code snippet:
int
main( int argc, char *argv[] )
{
int *i;
char *str, *str2, *str3;
int j;
int poolmax;
CYG_TEST_INIT();
CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library
"
"malloc(), calloc() and free() functions");
poolmax = mallinfo().maxfree;
if ( poolmax <= 0 ) {
CYG_TEST_FAIL_FINISH( "Can't determine allocation size to use" );
}
--------------------------------------------------
So it looks like mallinfo().maxfree is not returning the correct value.
My linker file looks like this:
STARTUP(vectors.o)
ENTRY(reset_vector)
INPUT(extras.o)
GROUP(libtarget.a libgcc.a libsupc++.a)
MEMORY
{
ram : ORIGIN = 0x81200000, LENGTH = 0x200000
rom : ORIGIN = 0x00000000, LENGTH = 0x200000
}
SECTIONS
{
.debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } .debug_info 0 : { *(.debug_info) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } .note.arm.ident 0 : { KEEP (*(.note.arm.ident)) }
.rom_vectors 0x00000000 : { __rom_vectors_vma = ABSOLUTE(.); . = .; KEEP (*(.vectors)) } > rom __rom_vectors_lma = LOADADDR(.rom_vectors);
.text ALIGN (1) : { _stext = ABSOLUTE(.); PROVIDE (__stext = ABSOLUTE(.)); *(.text*) *(.gnu.warning) *(.gnu.linkonce.t.*) *(.init) *(.glue_7) *(.glue_7t) } > rom _etext = .; PROVIDE (__etext = .);
.fini ALIGN (0x4) : { . = .; *(.fini) } > rom
.rodata ALIGN (0x4) : { . = .; *(.rodata*) *(.gnu.linkonce.r.*) } > rom
.rodata1 ALIGN (0x4) : { . = .; *(.rodata1) } > rom
.fixup ALIGN (0x4) : { . = .; *(.fixup) } > rom
.gcc_except_table ALIGN (0x4) : { . = .; *(.gcc_except_table) } > rom
.fixed_vectors 0x81200040 : { . = .; KEEP (*(.fixed_vectors)) } > ram
.data ALIGN (0x4) : AT ((LOADADDR (.gcc_except_table) + SIZEOF (.gcc_except_table) + 4 - 1) & ~ (4 - 1)) { __ram_data_start = ABSOLUTE (.); *(.data*) *(.data1) *(.gnu.linkonce.d.*) . = ALIGN (4); KEEP(*( SORT (.ecos.table.*))) ; . = ALIGN (4); __CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); __DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.); *(.dynamic) *(.sdata*) *(.gnu.linkonce.s.*) . = ALIGN (4); *(.2ram.*) } > ram __rom_data_start = LOADADDR (.data); __ram_data_end = .; PROVIDE (__ram_data_end = .); _edata = .; PROVIDE (edata = .); PROVIDE (__rom_data_end = LOADADDR (.data) + SIZEOF(.data));
.bss ALIGN (0x4) : { __bss_start = ABSOLUTE (.); *(.scommon) *(.dynsbss) *(.sbss*) *(.gnu.linkonce.sb.*) *(.dynbss) *(.bss*) *(.gnu.linkonce.b.*) *(COMMON) __bss_end = ABSOLUTE (.); } > ram
__heap1 = ALIGN (0x8);
. = ALIGN(4); _end = .; PROVIDE (end = .);
---------------------------------------------------------------------------
memalloc.h:
This would seem to indicate I have 16K for heap.
#ifndef CYGONCE_PKGCONF_MEMALLOC_H
#define CYGONCE_PKGCONF_MEMALLOC_H
/*
* File <pkgconf/memalloc.h>
*
* This file is generated automatically by the configuration
* system. It should not be edited. Any changes to this file
* may be overwritten.
*/
#define CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE 1
#define CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE 1
#define CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_COALESCE 1
#define CYGPKG_MEMALLOC_ALLOCATOR_DLMALLOC 1
#define CYGDBG_MEMALLOC_ALLOCATOR_DLMALLOC_DEBUG 1
#define CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_THREADAWARE 1
#define CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_SAFE_MULTIPLE 1
#define CYGIMP_MEMALLOC_ALLOCATOR_DLMALLOC_USE_MEMCPY 1
#define CYGNUM_MEMALLOC_ALLOCATOR_DLMALLOC_ALIGNMENT 3
#define CYGNUM_MEMALLOC_ALLOCATOR_DLMALLOC_ALIGNMENT_3
#define CYGSEM_MEMALLOC_ALLOCATOR_SEPMETA_THREADAWARE 1
#define CYGFUN_MEMALLOC_KAPI 1
#define CYGPKG_MEMALLOC_MALLOC_ALLOCATORS 1
#define CYGBLD_MEMALLOC_MALLOC_IMPLEMENTATION_HEADER
<cyg/memalloc/dlmalloc.hxx>
#define CYGIMP_MEMALLOC_MALLOC_DLMALLOC 1
#define CYGNUM_MEMALLOC_FALLBACK_MALLOC_POOL_SIZE 16384
#define CYGNUM_MEMALLOC_FALLBACK_MALLOC_POOL_SIZE_16384
#endif
----------------------------------------------------------------
In case this is useful:
#ifndef CYGONCE_PKGCONF_HEAPS_HXX
#define CYGONCE_PKGCONF_HEAPS_HXX
/* <pkgconf/heaps.hxx> */
/* This is a generated file - do not edit! */
#define CYGMEM_HEAP_COUNT 1
#include <cyg/memalloc/dlmalloc.hxx>
extern Cyg_Mempool_dlmalloc *cygmem_memalloc_heaps[ 2 ];
#endif
/* EOF <pkgconf/heaps.hxx> */
-------------------------------------------------------
If anyone else has already seen this and fixed it or can offer suggestions
on where to look next, as I further investigate this myself, I would
appreciate it.
Brett
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss