WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Segmentation fault  (Read 3096 times)

Offline asi3brg

  • Newbie
  • *
  • Posts: 9
Segmentation fault
« on: January 29, 2020, 07:04:04 AM »
I'm testing run in a tool the O.S. TinyCore were we execute a main SW that call a new shared object, LibCAN.so, to comunicate in a CAN BUS, but when we call this LibCAN.so we have a Segmentation fault, see img attached(running with GDB for more details).

We have a warning during compilation of this LibCAN.so, see img attached.

NOTE: Using this LibCAN.so in Ubuntu everything works as expected.

Some idea or hint?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11229
Re: Segmentation fault
« Reply #1 on: January 29, 2020, 07:40:42 AM »
Hi asi3brg
The  SIGSEGV  error shows an attempt to use address  0x00000000  which is not valid. I think you are going to have to install  gdb.tcz
to trace that error.

Offline asi3brg

  • Newbie
  • *
  • Posts: 9
Re: Segmentation fault
« Reply #2 on: January 31, 2020, 02:27:48 AM »
I' trying to compile in Tiny Core the main SW (that calls the shared object) and I' getting errors (ncurses is installed):

Code: [Select]
/mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:6418: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:6418: undefined reference to `wprintw'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:6418: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:6418: undefined reference to `wrefresh'
/usr/local/bin/ld: /tmp/ccsjBzuw.o: in function `UpdateCANDisplayLine':
/mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7598: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7602: undefined reference to `wmove'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7602: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7602: undefined reference to `wrefresh'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7603: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7603: undefined reference to `wprintw'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7603: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7603: undefined reference to `wrefresh'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7607: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7607: undefined reference to `wmove'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7607: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7607: undefined reference to `wrefresh'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7608: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7608: undefined reference to `wprintw'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7608: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7608: undefined reference to `wrefresh'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7610: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7610: undefined reference to `wmove'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7610: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:7610: undefined reference to `wrefresh'
/usr/local/bin/ld: /tmp/ccsjBzuw.o: in function `CanConfigureID':
/mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:780: undefined reference to `stdscr'
/usr/local/bin/ld: /mnt/sdb2/BBoxTeste/BlBox_SW/CAN.c:780: undefined reference to `wprintw'

    [EDIT]: Added code tags.  Rich
« Last Edit: January 31, 2020, 08:54:48 AM by Rich »

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Re: Segmentation fault
« Reply #3 on: January 31, 2020, 03:13:23 AM »
Hi, asi3brg!

If You want to compile some software You need to install corresponding *-dev extensions. For example to use libncurses* install ncurses-dev.

Offline asi3brg

  • Newbie
  • *
  • Posts: 9
Re: Segmentation fault
« Reply #4 on: January 31, 2020, 03:27:27 AM »
It was already installed.

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Re: Segmentation fault
« Reply #5 on: January 31, 2020, 05:06:39 AM »
Seem that You will need to take a closer look on the sources, including the make files. Try to compare, where include files are expected to be located, and their actual location.
And I see function wprintfw, which is wide-char version of wprintf, so You need ncursesw instead of ncurses.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11229
Re: Segmentation fault
« Reply #6 on: January 31, 2020, 08:52:44 AM »
Hi asi3brg
You should have  ncursesw-dev.tcz  (NOT  ncurses-dev.tcz)  installed. The headers are under  /usr/local/include/ncursesw/  so your
source file needs something like:
Code: [Select]
#include <ncursesw/ncurses.h>

Offline asi3brg

  • Newbie
  • *
  • Posts: 9
Re: Segmentation fault
« Reply #7 on: February 13, 2020, 07:26:55 AM »
I apologize for the late feedback, however, although it is a basic error, it can always help any beginner in a setup of this type where a shared library is called by a sw main. The problem was related to the permissions of this shared library, solved with the command chmod 755.