Hi Nazmul! On Wed, Aug 31, 2016 at 04:53:20PM +0000, Nazmul Alam wrote: > Sorry for the poor explanation.
No need to excuse here. :)
> I have created four tap devices. But the image was crashing before running
> the ccn-lite-relay example.
I was just checking, because this can sometimes cause weird error messages.
> 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).
Have you executed the elf by any chance directly like this:
./bin/native/ccn-lite-relay.elf
or did you use `make term`?
In the first case, you're right, there's an issue that native will call
printf() before tlsf got initialized and malloc() will fail. I will open an
issue.
> 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.
But if you don't want to use tlsf, you can simple remove it from the Makefile.
(But note that it won't work on most real devices then, because `free()` is
not implemented on most MCUs currently. (To be accurate: free() is available,
but sbrk() with negative values is not handled correctly.))
Cheers,
Oleg
--
printk("MASQUERADE: No route: Rusty's brain broke!\n");
linux-2.4.3/net/ipv4/netfilter/ipt_MASQUERADE.c
signature.asc
Description: PGP signature
_______________________________________________ users mailing list [email protected] https://lists.riot-os.org/mailman/listinfo/users
