Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Cleaner | Endless loop when "Files" cleaner active with files added for removal #2837

Closed
maartenlangeveld opened this issue May 20, 2019 · 8 comments
Labels
Bug 🐞 Solution available 🥂 Definite solution has been done
Milestone

Comments

@maartenlangeveld
Copy link

maartenlangeveld commented May 20, 2019

ADMIN EDIT

Solution

sed -i "/for i in \${!aCustomFiles\[@\]}/i\\\t\\t\\tlocal i=''" /DietPi/dietpi/dietpi-cleaner

'dietpicleaner 1' command seems to cause an endless loop...

...on both armv6 (rpi-zero-w) and aarch64 (nanopi-neo2)

[root@DietPi:~# dietpi-cleaner 1
[  OK  ] DietPi-Cleaner | Root access verified.
[  OK  ] DietPi-Cleaner | RootFS R/W access verified.
[ SUB1 ] DietPi-Services > stop
[ INFO ] DietPi-Services | Including custom service: upmpdcli
[ INFO ] DietPi-Services | Including custom service: minimserver
[  OK  ] DietPi-Services | stop : minimserver
[  OK  ] DietPi-Services | stop : upmpdcli
[  OK  ] DietPi-Services | stop : cron
[  OK  ] DietPi-Services | stop : mpd
[  OK  ] DietPi-Services | stop : lighttpd
[  OK  ] DietPi-Services | stop : php7.3-fpm
[  OK  ] DietPi-Services | stop : mariadb
[  OK  ] DietPi-Services | stop : nfs-kernel-server
[  OK  ] DietPi-Services | stop : smbd
[  OK  ] DietPi-Services | stop : nmbd
[  OK  ] DietPi-Services | stop : avahi-daemon



───────────────────────────────────────
DietPi-Cleaner
 - Man pages and docs
───────────────────────────────────────
E: No packages found
[ INFO ] DietPi-Cleaner | APT autoremove + purge, please wait...
[  OK  ] DietPi-Cleaner | G_AGA



───────────────────────────────────────
DietPi-Cleaner
 - Files
───────────────────────────────────────

Searching for filenames matching:
- *.tmp

Please wait...

No matching filenames were found.




───────────────────────────────────────
DietPi-Cleaner
 - Man pages and docs
───────────────────────────────────────
E: No packages found
[ INFO ] DietPi-Cleaner | APT autoremove + purge, please wait...
[  OK  ] DietPi-Cleaner | G_AGA



───────────────────────────────────────
DietPi-Cleaner
 - Files
───────────────────────────────────────

Searching for filenames matching:
- *.tmp

Please wait...

No matching filenames were found.




───────────────────────────────────────
DietPi-Cleaner
 - Man pages and docs
───────────────────────────────────────
E: No packages found
[ INFO ] DietPi-Cleaner | APT autoremove + purge, please wait...
[  OK  ] DietPi-Cleaner | G_AGA



───────────────────────────────────────
DietPi-Cleaner
 - Files
───────────────────────────────────────

Searching for filenames matching:
- *.tmp

Please wait...

No matching filenames were found.




───────────────────────────────────────
DietPi-Cleaner
 - Man pages and docs
───────────────────────────────────────
E: No packages found
[ INFO ] DietPi-Cleaner | APT autoremove + purge, please wait...
[  OK  ] DietPi-Cleaner | G_AGA



───────────────────────────────────────
DietPi-Cleaner
 - Files
───────────────────────────────────────

Searching for filenames matching:
- *.tmp

Please wait...

No matching filenames were found.



───────────────────────────────────────
DietPi-Cleaner
 - Man pages and docs
───────────────────────────────────────
E: No packages found
[ INFO ] DietPi-Cleaner | APT autoremove + purge, please wait...
[  OK  ] DietPi-Cleaner | G_AGA


> **and so on....**

@Fourdee
Copy link
Collaborator

Fourdee commented May 20, 2019

@maartenlangeveld

Many thanks for the report 👍

Confirmed bug when .tmp is enabled, looking into it now.

Seems i is being shared to sub functions as a global. Any i loop in sub function then returns value back to Run_Cleaners()?

Run_Cleaner_$i

probably due to below not inside func

for ((i=0; i<$MAX_CLEANERS; i++))
	do

		aEnabledCleaners[$i]=0

	done

@MichaIng
Copy link
Owner

Jep, i in the Run_Cleaner_$i function must be local. We generally need to take care to localize every i before loops in functions. I didn't notice since I had no files added, so I was not overridden.

@MichaIng MichaIng added this to the v6.25 milestone May 20, 2019
@MichaIng
Copy link
Owner

MichaIng commented May 20, 2019

@maartenlangeveld @Fourdee
That should be it: 75c5daa

  • Line 460 is the one required here.
  • But to be failsafe in general, we should localise every for-loop index inside a function once. When some script gets reordered, this proactively prevents similar issues, which not necessarily show up on every test, depending on used options/variables and such. In this case indeed files array needs to be filled (files added for removal) to run into the loop.

🈯️ Test passed
To solve now:

sed -i "/for i in \${!aCustomFiles\[@\]}/i\\\t\\t\\tlocal i=''" /DietPi/dietpi/dietpi-cleaner

@MichaIng MichaIng changed the title 'dietpi-cleaner 1' in an endless loop (DietPi v6.24.1) DietPi-Cleaner | Endless loop when "Files" cleaner active with files added for removal May 20, 2019
@maartenlangeveld
Copy link
Author

maartenlangeveld commented May 20, 2019

@MichaIng / @Fourdee,

Thanks.

sed -i "/for i in ${!aCustomFiles[@]}/i\\t\t\tlocal i=''" /DietPi/dietpi/dietpi-cleaner

Solved the problem :-)

@MichaIng
Copy link
Owner

@maartenlangeveld
Great, thanks for testing 👍.

@diveyez
Copy link

diveyez commented May 21, 2019

#2806 as seen in my images there, system was attempting to clean php and stuck in infinite loop as well. Dirty Dirty Packages. They should never have removed the crypto in php.

@MichaIng
Copy link
Owner

@diveyez
I can't see the images you mention, just the two about startup (with "A start job ..." hang and network interface error)?

system was attempting to clean php

You mean the systemd service that regularly cleans PHP sessions? That is not related to this issue then (dietpi-cleaner).

Dirty Dirty Packages

Yeah sounds like file corruption then, which might be also the reason for all the other issues you face/mention in the other topics.
dmesg can be used to check undervoltage, disk I/O errors and such, basically check for any red lines.
> forcefsck can be used to force a file system check on next reboot.

They should never have removed the crypto in php.

What you mean? I don't get the relation and PHP of course is still cryptography capable via OpenSSL module. They removed the obsolete outdated mcrypt module which is a security vulnerability only when being used, if that is what you mean.

@Fourdee
Copy link
Collaborator

Fourdee commented May 21, 2019

Confirmed resolved with dev, nice one @MichaIng 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐞 Solution available 🥂 Definite solution has been done
Projects
None yet
Development

No branches or pull requests

4 participants