WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Application segmentation fault after rebuilding kernel  (Read 1871 times)

Offline settimid

  • Newbie
  • *
  • Posts: 8
Application segmentation fault after rebuilding kernel
« on: November 13, 2023, 08:37:51 AM »
Hi all

I have a TC 3.8.4 with kernel 2.6.33.3-tinycore64 from here: http://distro.ibiblio.org/tinycorelinux/3.x/archive/3.8.4/distribution_files/ (file bzImage64)
All is fine, my C software run perfectly with this setup.

Now i try to rebuild kernel from source (as first step, without changing anything from its default)

Code: [Select]
wget http://distro.ibiblio.org/tinycorelinux/3.x/release/src/kernel/linux-2.6.33.3-patched.tbz2
wget http://distro.ibiblio.org/tinycorelinux/3.x/release/src/kernel/config-2.6.33.3-tinycore64
tar xf linux-2.6.33.3-patched.tbz2
cd linux-2.6.33.3
make mrproper
cp ../config-2.6.33.3-tinycore64 .config
make oldconfig
make

This create a bzImage under arch/x86/boot/bzImage that I copy as bzImage64 to replace the original one.

The OS boot up and all seem to be ok, except that if I run my C application i have a segmentation fault as soon as I call
Code: [Select]
gettimeofday() or
Code: [Select]
time() system function.

Googling about gettimeofday and segmentation fault this seem to be related to VDSO (Virtual Dynamically-linked Shared Object) https://man7.org/linux/man-pages/man7/vdso.7.html but I have no idea of how to solve this issue.

Any hint?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10969
Re: Application segmentation fault after rebuilding kernel
« Reply #1 on: November 13, 2023, 09:41:59 AM »
You also need to replace the modules if you used a different compiler version. Though your symptoms are rather curious, not sure what exactly is the cause.
The only barriers that can stop you are the ones you create yourself.

Offline settimid

  • Newbie
  • *
  • Posts: 8
Re: Application segmentation fault after rebuilding kernel
« Reply #2 on: November 15, 2023, 12:03:02 AM »
Hi curaga, here is something more about my setup

I build kernel source (and my software as well) using a Suse 11.3 64bit, that run a very similar kernel (2.6.34 x86_64).
My C code is compiled with static linking (gcc -static) as per requirement.

Quote
You also need to replace the modules if you used a different compiler version. Though your symptoms are rather curious, not sure what exactly is the cause.

Yes, I imagine it could be something like this, but what do you exactly mean?
Should I replace modules in my target tinycore or in my build machine (or both) and what is the correct procedure to do this?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10969
Re: Application segmentation fault after rebuilding kernel
« Reply #3 on: November 15, 2023, 09:46:34 AM »
You only copied bzImage to the target. You also need to copy the modules, via the "make modules_install INSTALL_MOD_PATH=/tmp/foo" command; replace the old modules inside the initrd with those, maybe pack some into extensions if you want.

The cause of your crash however could be in suse's glibc. It's possible it was set to require 2.6.34, and crashing on 2.6.33 in a time func could be caused by that.
edit: Oh, I just re-read your post, and you said your program works fine with the original kernel.
« Last Edit: November 15, 2023, 09:49:17 AM by curaga »
The only barriers that can stop you are the ones you create yourself.

Offline settimid

  • Newbie
  • *
  • Posts: 8
Re: Application segmentation fault after rebuilding kernel
« Reply #4 on: November 23, 2023, 06:00:46 AM »
Quote
You only copied bzImage to the target. You also need to copy the modules, via the "make modules_install INSTALL_MOD_PATH=/tmp/foo" command; replace the old modules inside the initrd with those, maybe pack some into extensions if you want.

Hi curaga
I tried to do as you suggest, i.e. compile the kernel modules and then update the microcore64.gz file by replacing the contents of the /lib/modules/2.6.33.3-tinycore64 folder (unpacking and packing it) but nothing changed.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10969
Re: Application segmentation fault after rebuilding kernel
« Reply #5 on: November 23, 2023, 09:35:43 AM »
Then it could be a compiler bug, something in that version of gcc miscompiling that version of kernel. But really hard to say.
The only barriers that can stop you are the ones you create yourself.

Offline CentralWare

  • Administrator
  • Hero Member
  • *****
  • Posts: 1652
Re: Application segmentation fault after rebuilding kernel
« Reply #6 on: November 24, 2023, 05:52:15 PM »
You also need to replace the modules if you used a different compiler version. Though your symptoms are rather curious, not sure what exactly is the cause.
@settimid: Just for sake of curiosity:
  • What version of TinyCoreLinux did you initially install on the device?
  • Is there cause for why we're using version 3.x? (We're currently at 14.x)
  • Is the device in question 64 bit (since your downloaded kernel config file is)
« Last Edit: November 24, 2023, 05:59:42 PM by CentralWare »
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline gadget42

  • Hero Member
  • *****
  • Posts: 663
Re: Application segmentation fault after rebuilding kernel
« Reply #7 on: November 24, 2023, 11:04:58 PM »
@settimid: Just for sake of curiosity:
....
Is there cause for why we're using version 3.x?
....

also with reference to version 3.x(link to removal advisement/post):
https://forum.tinycorelinux.net/index.php/topic,26497.0.html
The fluctuation theorem has long been known for a sudden switch of the Hamiltonian of a classical system Z54 . For a quantum system with a Hamiltonian changing from... https://forum.tinycorelinux.net/index.php/topic,25972.msg166580.html#msg166580

Offline CentralWare

  • Administrator
  • Hero Member
  • *****
  • Posts: 1652
Re: Application segmentation fault after rebuilding kernel
« Reply #8 on: November 25, 2023, 12:26:13 AM »
Thanks @gadget42, I still have yet to sync our mirror before the repo gets Spring Cleaning! :)
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline settimid

  • Newbie
  • *
  • Posts: 8
Re: Application segmentation fault after rebuilding kernel
« Reply #9 on: November 30, 2023, 01:27:12 AM »
You also need to replace the modules if you used a different compiler version. Though your symptoms are rather curious, not sure what exactly is the cause.
@settimid: Just for sake of curiosity:
  • What version of TinyCoreLinux did you initially install on the device?
  • Is there cause for why we're using version 3.x? (We're currently at 14.x)
  • Is the device in question 64 bit (since your downloaded kernel config file is)

Hi @CentralWare

That said, I would now need to recompile the kernel in question to get motherboard buzzer support, which doesn't seem to be enabled by default.

I download kernel source and re-build kernel, with the procedure I wrote in my first post.
Then updated mu USB key with bzImage64 i build up and (as a second try) with the microcore64 re-packed with the modules I build.


OS boot up correctly, beep works, uname show correct information, but my C application suddenly crash (segfault)
If I comment out all call to gettimeofday() and time() system function my application run, but of course I need them.

I use a Suse 11.3 64bit, that run a very similar kernel (2.6.34 x86_64) to build both kernel and my application.

Offline settimid

  • Newbie
  • *
  • Posts: 8
Re: Application segmentation fault after rebuilding kernel
« Reply #10 on: November 30, 2023, 01:32:30 AM »
also with reference to version 3.x(link to removal advisement/post):
https://forum.tinycorelinux.net/index.php/topic,26497.0.html

@gadget42 Thank you very much for alerting me to this. I owe you a beer.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11256
Re: Application segmentation fault after rebuilding kernel
« Reply #11 on: November 30, 2023, 06:24:46 AM »
Hi settimid
... Critical industrial applications do not easily accommodate upgrades. ...
Understood. However, if TC4 is acceptable, it has the PC speaker enabled.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10969
Re: Application segmentation fault after rebuilding kernel
« Reply #12 on: November 30, 2023, 09:47:21 AM »
It's also likely that TC4's kernel would run fine on TC3, if you want to change only one component.
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11256
Re: Application segmentation fault after rebuilding kernel
« Reply #13 on: November 30, 2023, 10:44:50 AM »
Hi curaga
TC3=2.6.33
TC4=3.0.21
Did those older kernels allow loading non-matching modules?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10969
Re: Application segmentation fault after rebuilding kernel
« Reply #14 on: November 30, 2023, 11:47:46 PM »
No, but I'd consider the kernel and modules one component in a sense. I did write a bit unclearly.
The only barriers that can stop you are the ones you create yourself.