Segmentation fault on example

Hi all,

I recently found RIOT OS and decide to give it a try. However, I got segmentation fault when I tried to run the example. Here is the step I take:

  • clone the RIOT source git clone https://github.com/RIOT-OS/RIOT.git
  • compile the example for linux machine (I already have the GCC toolchains installed) cd examples/hello-world make
  • run the example (the .elf file)

./bin/native/hello-world.elf Segmentation fault I also tried other example (default) without luck. Is there something that I miss? I have not changed anything on the makefile, and I check that the BOARD is native, which is the correct target (according to the RIOT wiki) if I want to run it on linux machine.

Thanks. Regards,

Hi Victor,

which versions of gcc, libc and Linux are you using, and on which architecture are you running it?

With current master I don't have any trouble with:     cd examples/hello-world     make -B clean all     make term

Cheers, Ludwig

Hi Victor,

I don't know what's wrong there.. As the support for your Ubuntu version is running out shortly I won't look into it.

Maybe you can upgrade your Ubuntu to 13.10, Saucy Salamander. I know it's working there.

Otherwise I can only do some wild guessing now - maybe there are some CFLAGS in your environment (env / echo $CFLAGS)? Does the binary really use the correct libraries (ldd bin/native/*elf)?

You could also rebuild with "CFLAGS=-g make -B clean all" and run in gdb ("make debug", gdb command: "run") and investigate the segfault (gdb command: "bt full").

Cheers, Ludwig

Hi Ludwig,

i am having the same problem as reported below by Victor.

I did: $ git clone https://github.com/RIOT-OS/RIOT.git $ cd RIOT/examples/hello-world $ make -B clean all $ make term /home/***/RIOT/examples/hello-world/bin/native/hello-world.elf make: *** [term] Segmentation fault (core dumped)

A couple of weeks ago (before the announcement of release 2014.01), i already had a go on RIOT, and i am pretty sure - yet without proof! - that i was able to run the hello world example on the native build. Now i did a git clone again.

My system is: - Ubuntu 12.04.4 LTS, x86/32bit - As cross compiler i use the binaries from https://launchpad.net/gcc-arm-embedded, version gcc-arm-none-eabi-4_8-2013q4

For the versions i'm not so sure, so i try to give some hints:

GCC-Version: $ cd   ./gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc --version arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3 20131129 (release) [ARM/embedded-4_8-branch revision 205641] Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For the libc, i really don't know(, also not much about it!). When i run as proposed in http://stackoverflow.com/questions/9705660/check-glibc-version-for-a-particular-gcc-compiler to find out the version, $ gcc glibc-version.c -o glibc-version $ ./glibc-version GNU libc version: 2.15

But, compiling it with the cross-compiler (above), doesn't work $ ~/gcc-arm-none-eabi-4_8-2013q4/arm-none-eabi/bin/gcc glibc-version.c -o glibc-version gcc: error trying to exec 'cc1': execvp: No such file or directory

and also $ ~/gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc glibc-version.c -o glibc-version glibc-version.c:3:30: fatal error: gnu/libc-version.h: No such file or directory   #include <gnu/libc-version.h>                                ^ compilation terminated.

Looks like either - i don't have libc ready for cross-compiling...? - Don't know how to use my cross-compiler...

Do you have any suggestions?

Thanks, Janos

One more info: my native GCC version is $gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

Cheers Janos

Hi Ludwig,

concerning this issue from the users list, i though with these new clues it's more a developer thing?

I tracked down the commit, after which things don't work for me, on both my ubuntu machines (although almost identical setup, except hardware).

when i do      $ git log i get, among others:

     commit 4939473afbcfe981b6411595a3b73e792ae28775      Author: Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>

I'll look into it when I'm back on my feet.

Cheers, Ludwig

Hi Ludwig,

I am going to take your suggestion to use newer distro since I have no problem with that yet.

in case you are still interested, below are some info related to your last email:

  • I have no CFLAGS set on my environment.
  • output of ldd bin/native/*elf is: linux-gate.so.1 => (0xf7716000) libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf76e7000) librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xf76de000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7533000) /lib/ld-linux.so.2 (0xf7717000) libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf7518000)
  • I added the “CFLAGS=-g make -B clean all” on the makefile, rebuild it and run it on gdb. Here is the output of bt full: (gdb) bt full #0 0x00000000 in ?? () No symbol table info available. #1 0x0804a970 in calloc () No symbol table info available. #2 0x555a23ae in ?? () from /lib/i386-linux-gnu/libdl.so.2 No symbol table info available. #3 0x555a1de4 in dlsym () from /lib/i386-linux-gnu/libdl.so.2 No symbol table info available. #4 0x0804917b in startup () No symbol table info available. #5 0x0804b962 in __libc_csu_init () No symbol table info available. #6 0x555c946a in __libc_start_main () from /lib/i386-linux-gnu/libc.so.6 No symbol table info available. #7 0x08048ca1 in _start () No symbol table info available.

Thanks. Regards,

One more info: my native GCC version is $gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

Cheers Janos

Hi Janos,

as you might have noticed, I opened a PR that addresses the problem: https://github.com/RIOT-OS/RIOT/pull/762

Please check if it works for you: $ git remote add ludwig https://github.com/LudwigOrtmann/RIOT $ git fetch ludwig $ git checkout issue_741

Build your application, run it, post a comment (preferably in github) whether it fixes the problem.

Once the PR has been merged, go back to master: $ git checkout master

Cheers, Ludwig

Hi Victor,

Thank you for your cooperation, I think the issue has been resolved with this PR: https://github.com/RIOT-OS/RIOT/pull/762

If you did not get around to upgrading your distro yet, it might work with that patch.

Check here for instructions: http://lists.riot-os.org/pipermail/devel/2014-February/000558.html

Cheers, Ludwig

Hi Ludwig,

i have by now also updated my ubuntu to the Saucy Salamander, where this problem doesn't occur.

To reproduce the problem and check the solution, i set up a Virtualbox VM with Ubuntu 12.04 Precise, set up the toolchain, checked out master of RIOT, built and ran, and saw the segmentation fault. After checking out the issue_741, i built and ran the hello-world example, and it worked fine.

Thanks for your support!

Cheers Janos

Thanks a lot! The PR has been merged.

Cheers, Ludwig