[RTEMS Project] #4764: msdos_format throws RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE on free(fmt_params.sec)

RTEMS trac trac at rtems.org
Mon Nov 28 10:02:58 UTC 2022

#4764: msdos_format throws RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE on
 Reporter:  Giovanni Righi  |       Owner:  (none)
     Type:  defect          |      Status:  new
 Priority:  high            |   Milestone:  5.1
Component:  fs/fat          |     Version:  5
 Severity:  major           |  Resolution:
 Keywords:                  |  Blocked By:
 Blocking:                  |

Comment (by Giovanni Righi):

 Ok I found something interesting.
 First of all if I compile the rtems code with the flag --enable-rtems-
 debug the malloc of fmt_params.sec doesn't work so the pointer it's NULL
 and the function tries to free a NULL pointer. I don't know if the malloc
 not allocating is an expected behaviour in this condition.
 But if I remove the flag and recompile the kernel the malloc is working
 and everything seems to work smootly until I get to the free.
 The pointer now it's allocated and it contains the stuff that is being
 written in the external flash.
 Here's what the pointer contains when the free it's called.
 Now the free stil doesn't work and returns the same error as before.
 This obviusly causes my RTEMS app to stop working.
 If I reboot the app the msdos_format it's called again but in this case
 the external memory is not erased since the function called in the
 previous execution was formatting the external memory with the FAT
 So now I got a crc error. I suppose this is because the previous execution
 was stopped and the QSPI driver hadn't finished writing to external
 He's a screen shot of the full error.
 The interesting thing is that now the free works and my application keeps
 working as we can see from the screenshot.
 Obviusly the filesystem is not mounted so it's still working in the IMFS

Ticket URL: <http://devel.rtems.org/ticket/4764#comment:2>
RTEMS Project <http://www.rtems.org/>
RTEMS Project

More information about the bugs mailing list