[riot-users] ccnx-lite-relay example crashing in native board

Nazmul Alam fadedreamz at gmail.com
Wed Aug 31 18:53:20 CEST 2016


Hi Oleg,

Sorry for the poor explanation.

I have created four tap devices. But the image was crashing before running
the ccn-lite-relay example.

Following stacktrace suggests that it crashed inside the printf function
which tries to use the malloc defined in tlsf.

> #3  0x0805a26c in malloc (bytes=1024)
>     at /home/fadedreamz/riotos/RIOT/examples/ccn-lite-relay/bin/
> pkg/native/tlsf/src/tlsf-malloc.c:9
> ...
> #8  0xf7e41d17 in vfprintf () from /lib32/libc.so.6
> #9  0xf7e48f66 in printf () from /lib32/libc.so.6
> #10 0x08049749 in usage_exit ()
>     at /home/fadedreamz/riotos/RIOT/cpu/native/startup.c:198
> #11 0x08048eb4 in startup (argc=1, argv=0xffffd024)
>
But tlsf malloc will work only if is initialized previously with
tlsf_create_with_pool() (as per my understanding).

Following lines defined in tlsf-malloc.h

> #ifndef TLSF_MALLOC_PREFIX
> #   define TLSF_MALLOC_PREFIX
> #endif
> #define __TLSF_MALLOC_NAME(A, B) A ## B
> #define _TLSF_MALLOC_NAME(A, B) __TLSF_MALLOC_NAME(A, B)
> #define TLSF_MALLOC_NAME(NAME) _TLSF_MALLOC_NAME(TLSF_MALLOC_PREFIX, NAME)
> ...
> void *TLSF_MALLOC_NAME(malloc)(size_t bytes);
>
is expanded into

> void * malloc(size_t bytes);
>
if TLSF_MALLOC_PREFIX is not defined

So, I think linker uses the malloc version defined into tlsf for printf,
which was causing the crash (due to control structure being pointed to
null).

defining the TLSF_MALLOC_PREFIX forces the linker to use correct malloc.

I used fresh copy of RIOT-OS and build the stock ccn-lite-relay example
without any modification in Ubuntu 16.04.
Regards,
Nazmul

On Aug 31, 2016 5:23 AM, "Oleg Hahm" <oliver.hahm at inria.fr> wrote:

> Hi Nazmul,
>
> On Tue, Aug 30, 2016 at 11:50:20PM +0000, Nazmul Alam wrote:
> > The issue previously mentioned was due to same signature of two different
> > types of malloc/free function.
> > The malloc/free used by printf was causing the crash as it was trying to
> > use the malloc/free defined from tlsf library, causing the call to
> > search_suitable_block() before actually allocating memory by the library.
> >
> > It can be solved by adding following define in the Makefile to specify
> any
> > prefix for the tlsf specific malloc/free
> >
> > CFLAGS += -DTLSF_MALLOC_PREFIX=mytlsf_
> >
> > this will make tlsf malloc to become mytlsf_malloc/mytlsf_free and then
> the
> > printf will use the correct malloc/free function.
>
> I'm not sure I understand the problem.
> First of all, the ccn-lite-relay example works perfectly fine on native
> when I
> try it.
> Second, it is supposed to use tlsf for malloc instead of the host system's
> malloc implementation. TLSF works fine on native and other 32 bit platforms
> that I tested.
>
> Have you made sure that you have created at least on tap device?
>
> Cheers,
> Oleg
> --
> The worst thing about Perl jokes is that next morning you can't understand
> why
> they seemed so funny.
>
> _______________________________________________
> users mailing list
> users at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/users/attachments/20160831/97c2207d/attachment.html>


More information about the users mailing list