Menu

#645 _sbrk_r with incr == 0 should be valid

3.0.3
closed
None
Medium
3.0.2
True
2015-11-08
2015-09-28
Paul Szego
No

In os/various/syscalls.c, in function _sbrk_r: if called with 'incr' of zero fails due to this line:

chDbgCheck(incr > 0);

According to some definitions I've found, if called with incr == 0 it should return the current end of the heap, and not fail. And i'm seeing it get called that way when linking with g++.

To get my system working I hacked this into the function, but it's not a general solution (the return value isn't even accurate, it's just something to stop the runtime errors):

  extern caddr_t __heap_base__;

  if ( incr == 0 ) {
      return __heap_base__;
  }

Is there a proper way to do this?

Some linker settings that may be pertinent (not the complete command line):

arm-none-eabi-g++ -nostartfiles -nodefaultlibs -nostdlib --specs=nano.specs --specs=nosys.specs -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys

Discussion

  • Giovanni Di Sirio

    • assigned_to: Giovanni Di Sirio
    • Fixed in Repository: False --> True
     
  • Giovanni Di Sirio

    Hi,

    Just the chDbgCheck() needs a change, chCoreAlloc() behaves as expected. I committed the change to the check.

    Giovanni

     
  • Giovanni Di Sirio

    • status: open --> closed
     

Log in to post a comment.