WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Removing SDCARD results in segmentation fault  (Read 1818 times)

Offline segfault

  • Newbie
  • *
  • Posts: 27
Removing SDCARD results in segmentation fault
« on: July 07, 2024, 06:19:22 AM »
Is there anyone out there who has any idea on what to do if I want to be able to run firefox (or chromium) without a SDCARD in the device, without the browser crashing?

So far I tried
First I start firefox, then I physically remove the SDCARD, then firefox crashes (only happens if SDCARD is removed and 100% reproducible). The error output reads "Segmentation fault".

I run "ps", then run "fuser -m /dev/mmcblk0p2" and see that firefox is using /mnt/mmcblk0p2. I try "umount -f /dev/mmcblk0p2" buy get a device busy error.

I then add firefox to copy2fs.lst and noswap to config, but firefox still crashes if I remove the SDCARD.

I then run "sudo umount -a" and now /dev/mmcblk0p2 gets unmounted. But firefox will crash after a while. This time it will take longer time (still measured in minutes) before it crashes, but it will crash eventually.

If I haven't started Firefox I can not start it after having un-mounted mmcblk0p2, but if I have started it, it seems to be still in RAM because I can restart it again after the crash, but will eventually crash never the less.




Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Removing SDCARD results in segmentation fault
« Reply #1 on: July 07, 2024, 08:14:55 AM »
Hi segfault
Welcome to the forum.

See if replacing copy2fs.lst with an empty file called copy2fs.flg fixes it.

Offline segfault

  • Newbie
  • *
  • Posts: 27
Re: Removing SDCARD results in segmentation fault
« Reply #2 on: July 07, 2024, 01:09:25 PM »
Thanks for the welcome and ur comment Rich!  ;D

I did "cd /mnt/mmcblk0p2/tce && rm copy2fs.lst && touch copy2fs.lst && sudo reboot".
Now loading extensions takes considerably longer time and eventually I get error: cp: write error: No space left on device.

I'm doing this on a Raspberry Pi 2 B v 1.1, so maybe not such surprising result. I've got basically the default version of piCore and save for Vim I've not downloaded any other extensions then firefox.

Is there something else I could try?
Maybe I could specify the dependencies the browser is using and add those to the copy2fs.lst list file?
I'm not sure which these are, but I think it at least lists some extensions it needs to download in order to run (it could still be using some other extensions already pre-downloaded though).

Any ideas?

PS! First impression of tinycore is great :)... very cool to be able to mess around and learn the ins- and out and not having to worry about permanently damaging the OS... just reboot. Really nice!!!

EDIT: Just noticed that the Apps app has a tab for all the dependencies.
EDIT2: And in optional folder I found firefox.tcz.dep file... but only the whole tree is not listed. But using tce-ab I can navigate in the terminal and look at the dependency tree. I will copy these to copy2fs.lst and see what happens.
« Last Edit: July 07, 2024, 01:24:32 PM by segfault »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Removing SDCARD results in segmentation fault
« Reply #3 on: July 07, 2024, 01:25:55 PM »
Hi segfault
You can't have it both ways. If you want to be able to remove the card, any
extension and its dependencies that get loaded must be copied to RAM.

... Now loading extensions takes considerably longer time and ...
It takes longer to copy extensions to RAM than to simply loop mount them.

Quote
... Is there something else I could try?
Maybe I could specify the dependencies the browser is using and add those to the copy2fs.lst list file? ...
Eventually something will attempt to access some other extension you're
loading and you'll segfault again.
If you need to pull the SD card, and you are short on RAM, I suggest
removing any extensions you don't need from  onboot.lst  so they
don't get loaded.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 724
Re: Removing SDCARD results in segmentation fault
« Reply #4 on: July 07, 2024, 03:11:22 PM »
 No space left on device.
Did you forget to expand the partision.
Or is it you memory size to small.

http://tinycorelinux.net/6.x/armv6/releases/README

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Removing SDCARD results in segmentation fault
« Reply #5 on: July 07, 2024, 03:30:09 PM »
Hi patrikg
He wants to run Firefox without the SD card plugged in.
That means all extensions that get loaded must be in RAM
so he can unmount the device and unplug it. He currently
needs more RAM than he has.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 724
Re: Removing SDCARD results in segmentation fault
« Reply #6 on: July 07, 2024, 04:42:39 PM »
Hi @Rich

Okey, i think picore also setup'ping swap zram default.
You can disable that maybe to increase some memory,
with kernel command line arg NOZSWAP
An you could aslo try to change the gpu mem size to lover in the config.txt file, with out losing the gpu(head)

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1270
Re: Removing SDCARD results in segmentation fault
« Reply #7 on: July 07, 2024, 09:31:59 PM »
I don’t see a pi2b having enough memory to do this.

Offline segfault

  • Newbie
  • *
  • Posts: 27
Re: Removing SDCARD results in segmentation fault
« Reply #8 on: July 08, 2024, 04:12:37 AM »
I don’t see a pi2b having enough memory to do this.

This has been my fear, but I'm pretty bold person so I'm willing to give it a try  8) ;)
No space left on device.
Did you forget to expand the partision.
Or is it you memory size to small.
http://tinycorelinux.net/6.x/armv6/releases/README

I have increased the partition, but I think the error occurs because I'm just pulling the SDCARD physically without even unmounting it first.  :o

You can disable that maybe to increase some memory,
with kernel command line arg NOZSWAP
An you could aslo try to change the gpu mem size to lover in the config.txt file, with out losing the gpu(head)

Great! I'll try this!

Offline segfault

  • Newbie
  • *
  • Posts: 27
Re: Removing SDCARD results in segmentation fault
« Reply #9 on: July 08, 2024, 05:35:33 AM »
Logged in with SSH I ran "tc-ab" and used the Tree dependency list view and wrote down all the dep to firefox. After removing the duplicate .tcz deps from the list, I added them to copy2fs.lst. I added noswap and nozswap to /mnt/mmcblk0p1/cmdline.txt.

After having removed all other extensions from copy2fs.lst and onboot.lst, save for TC, firefox and the dependencies firefox had, I rebooted and tarted firefox. Then running "free -m" told me there is still 585 left available of a total of 922 (swap was 0),

Removing the SDCARD still results in firefox crashing after a while. Clicking the firefox icon re-launches firefox even after SDCARD have been physically removed.

From what I gather, there is still memory left, but also there are files open on /mnt/mmcblk0p2.

Any ideas on how I should proceed? Maybe try to create a tombstone / crash dump and look for filedescriptors or something, to learn what code is trying to access the SDCARD?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1270
Re: Removing SDCARD results in segmentation fault
« Reply #10 on: July 08, 2024, 07:58:21 AM »
If all you are running is Firefox, you don’t need a window manager, just Xorg.   I do this with Chrome for a kiosk type display.  That would save some extension space in Ram.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Removing SDCARD results in segmentation fault
« Reply #11 on: July 08, 2024, 08:57:56 AM »
Hi segfault
... and used the Tree dependency list view and wrote down all the dep to firefox. After removing the duplicate .tcz deps from the list, I added them to copy2fs.lst. ...
Doing that is highly error prone. If you viewed the tree list on your
system, a copy will be present in /tmp. So you can:
Code: [Select]
awk '$1=$1' /tmp/firefox.tcz.tree | uniq -u > firefox.depsYou now have a file that contains both direct and indirect dependencies
for firefox with duplicate entries removed.

By the way, I don't see were you mentioned doing the same for TC.tcz.

Now if you want to simplify your life:
Code: [Select]
cd /mnt/mmcblk0p2/tce
rm copy2fs.lst
touch copy2fs.flg
echo TC.tcz > onboot.lst
echo firefox.tcz >> onboot.lst
Using copy2fs.flg copies all extensions to RAM, which is what you want.
Using copy2fs.lst copies select extensions to RAM, which is not what you want.

Offline segfault

  • Newbie
  • *
  • Posts: 27
Re: Removing SDCARD results in segmentation fault
« Reply #12 on: July 10, 2024, 03:54:39 AM »
If all you are running is Firefox, you don’t need a window manager, just Xorg.   I do this with Chrome for a kiosk type display.  That would save some extension space in Ram.

I didn't know. Thank!  :D

Rich:
Thanks a lot for your comments. Very nice, now it can be semi-automated; I will update my install-scripts accordingly! :D

Using copy2fs.flg copies all extensions to RAM, which is what you want.
Using copy2fs.lst copies select extensions to RAM, which is not what you want.

On rpb2v11 that flag option (copy2fs.flg) resulted in an out-of-memory. With the list option, it fits in memory (though firefox still crashes after a while):

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Removing SDCARD results in segmentation fault
« Reply #13 on: July 10, 2024, 08:31:02 AM »
Hi segfault
You're still missing the point. All extensions + dependencies that you
want to load must be in RAM.
If you want to load firefox.tcz
    then everything in firefox.tcz.tree must be in RAM
If you want to load Xorg.tcz
    then everything in Xorg.tcz.tree must be in RAM
If you want to load flwm_topside.tcz
    then everything in flwm_topside.tcz.tree must be in RAM
 ... and so on.

... On rpb2v11 that flag option (copy2fs.flg) resulted in an out-of-memory. ...
That may be, but for each extension listed in onboot.lst, it loads the contents
of its tree file.

Quote
... With the list option, it fits in memory (though firefox still crashes after a while):
Then something is likely still getting loop mounted. Take a look
in  /tmp/tcloop/ , there should be no extensions listed in there.

Using the  nozswap  boot code is a good idea. The zswap routine
takes 25% of free memory. zswap does you no good if you don't
have enough RAM for loading extensions to begin with.

If you want to see how much RAM is being used for zswap:
Code: [Select]
cat /sys/block/zram0/disksizeIt should be 0.

Offline segfault

  • Newbie
  • *
  • Posts: 27
Re: Removing SDCARD results in segmentation fault
« Reply #14 on: July 13, 2024, 05:46:42 AM »
You're still missing the point.
Correct.

Then something is likely still getting loop mounted. Take a look
in  /tmp/tcloop/ , there should be no extensions listed in there.

If you want to see how much RAM is being used for zswap:
Code: [Select]
cat /sys/block/zram0/disksizeIt should be 0.

Super helpful tidbits of info. I written this down!

Happy joy, it now works
I did a fresh install of piCore on my Raspberry Pi 2 Model B V1.1
Resized p2.
Installed TC.tcz and firefox.tcz
Added the copy2fs.flg to the tce folder.
Added TC.tcz and firefox.tcz to onboot.lst.
And turned off swap.
After rebooting the computer, it started the desktop.
I clicked the firefox icon and the browser opened up.
Then I physically removed the SDCARD from the device.
Opened developer tools etc,.
and then left it alone an hour.
Firefox doesn't seem to crash any longer.
And perhaps more importantly /tmp/tcloop/ is empty.

Though everything actually works out-of-the-box (as long as the user do not {un-intentionally} damage the system), a huge thanks for all the constructive feedback... I would probably have given up if I had to it on my own. : :-*
« Last Edit: July 13, 2024, 05:50:19 AM by segfault »