calloc returns null at91sam7s256

Bug #1442177 reported by Voland
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
New
Undecided
Unassigned

Bug Description

When I do first calloc after restart calloc returns null, when i debug my _sbrk_r func i see that newlib wants to allocate over 0x53bfdcf9 bytes. on old yagarto toolchain there are 0x218 bytes which seems to be ok and everything works fine. I assume this is toolchain bug.

 45 void * _sbrk_r(
 46 struct _reent *_s_r,
 47 ptrdiff_t nbytes)
 48 {
 49 char *base; /* errno should be set to ENOMEM on error */
 50
 51 if (!heap_ptr) { /* Initialize if first time through. */
 52 heap_ptr = end;
 53 }
 54 base = heap_ptr; /* Point to end of heap. */
 55 heap_ptr += nbytes; /* Increase heap. */
 56 DPRINTLN3("heap_ptr %x, base %x, nbytes %x", heap_ptr, base, nbytes);
 57
 58 return base; /* Return pointer to start of new heap area. */
 59 }

Revision history for this message
Voland (voland83) wrote :

it was my mistake _sbrk_r should take one argument, i don't know why two argument version works on older compilers over 3 years, please remove this bug.

Revision history for this message
Voland (voland83) wrote :

I'am sorry, i chanched my mind, the problem still ocurs.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

Can you see the symbol "end" being defined in the map file? You can obtain a map file by passing "_wl,-Map=map" to the GCC command line for linking. If not, can you show the linker script you are using?

Best regards,

Thomas

Revision history for this message
Voland (voland83) wrote : Re: [Bug 1442177] Re: calloc returns null at91sam7s256
  • map Edit (285.4 KiB, application/octet-stream; name=map)
  • flash.lds Edit (2.7 KiB, application/octet-stream; name="flash.lds")

2015-04-10 10:09 GMT+02:00 Thomas Preud'homme <email address hidden>:

> _wl,-Map=map

--
A.G.

Revision history for this message
Voland (voland83) wrote :

I made printf for (int)end and it seems to me that value of end is ok.

Revision history for this message
Voland (voland83) wrote :

linker script

Revision history for this message
Voland (voland83) wrote :

anyway everything worked fine until i changed new ubuntu distro and changed toolchain from summon arm toolchain to newest gnu toolchain. now even old gnu toolchain from 2012 dont work properly.

Revision history for this message
Voland (voland83) wrote :

I have to confess that when i reset at91sam7s256 on yagarto compilers it just runs properly but on newest gnu arm toolchain it hangs for couple seconds and then after couple watchdog resets it runs correctly. what is weird to me, first nbytes wanted by calloc in _sbrk_r are random but always to big like 0x53bfdcf9.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.