Page 2 of 2
Re: chibiOS 3 'chHeapAlloc' usage
Posted: Thu Apr 02, 2015 12:59 pm
by Giovanni
That assertions indicates that an attempt to release a mutex not owned.
Could you post the stack trace at that point?
Giovanni
Re: chibiOS 3 'chHeapAlloc' usage
Posted: Fri Apr 03, 2015 6:59 am
by JoVM
This is a trace from the
main thread.
Code: Select all
#0 chSysHalt (reason=reason@entry=0x80036f0 <__func__.6584> "chMtxUnlock")
at ../../../os/rt/src/chsys.c:164
#1 0x08001262 in chMtxUnlock (mp=mp@entry=0x20001630 <default_heap+16>)
at ../../../os/rt/src/chmtx.c:327
#2 0x080018e2 in chHeapAlloc (heapp=0x20001620 <default_heap>,
heapp@entry=0x0, size=size@entry=64) at ../../../os/rt/src/chheap.c:185
#3 0x08002b40 in initWithSizeAndIncRate (list=0x200007e8,
list@entry=0x200007c8, size=size@entry=16, rate=rate@entry=50)
at ArrayList.c:26
#4 0x08002b68 in initWithSize (size=16, list=list@entry=0x200007c8)
at ArrayList.c:19
#5 init (list=list@entry=0x200007e8) at ArrayList.c:14
#6 0x080001e4 in main () at main.c:96
Re: chibiOS 3 'chHeapAlloc' usage
Posted: Fri Apr 03, 2015 7:43 am
by Giovanni
It makes no sense. Heap allocator is used in a lot of places so it cannot just fail that way, there must be something else not so evident.
Giovanni
Re: chibiOS 3 'chHeapAlloc' usage
Posted: Fri Apr 03, 2015 7:59 am
by JoVM
@Giovanni:

Is the mutex not owned by the thread? How can I check this?
Re: chibiOS 3 'chHeapAlloc' usage
Posted: Fri Apr 03, 2015 8:04 am
by Giovanni
It cannot be not taken because chHeapAlloc() does that at very beginning....
This makes me think the problem is not so obvious. Do you use allocator functions in other places of the code? is it possible you have stack overflows?
Giovanni
Re: chibiOS 3 'chHeapAlloc' usage
Posted: Fri Apr 03, 2015 8:13 am
by JoVM
OOOhhhh, I use alloc before halinit and chSysInit. I think this is a bad idea.
My __main_stack_size__=0x400. So I think I'm save here on stack size.
Re: chibiOS 3 'chHeapAlloc' usage
Posted: Fri Apr 03, 2015 8:16 am
by JoVM
Sorry for the uphold.

Re: chibiOS 3 'chHeapAlloc' usage
Posted: Fri Apr 03, 2015 8:19 am
by Giovanni
Definitely a bad idea

Giovanni