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-Software | Mono: Current version fails on ARM #2219

Closed
MichaIng opened this issue Nov 3, 2018 · 12 comments
Closed

DietPi-Software | Mono: Current version fails on ARM #2219

MichaIng opened this issue Nov 3, 2018 · 12 comments
Assignees
Labels
External bug 🐞 For bugs which are not caused by DietPi. Information ℹ️ Solution available 🥂 Definite solution has been done Unable to replicate ☕ Via Forum

Comments

@MichaIng
Copy link
Owner

MichaIng commented Nov 3, 2018

Forum ref: https://dietpi.com/phpbb/viewtopic.php?f=11&t=5206
Related Sonarr issue: Sonarr/Sonarr#2769
Related Mono issue: mono/mono#11095

Current workaround is to add -O=-aot option to mono call, e.g.:
/usr/bin/mono -O=-aot /opt/NzbDrone/NzbDrone.exe -nobrowser -data=/mnt/dietpi_userdata/sonarr

@MichaIng MichaIng added Via Forum Solution available 🥂 Definite solution has been done External bug 🐞 For bugs which are not caused by DietPi. Information ℹ️ ARMbaby labels Nov 3, 2018
@Fourdee
Copy link
Collaborator

Fourdee commented Nov 4, 2018

  • 🈯️ ARMv7 With -O=-aot
  • 🈯️ ARMv7 Without -O=-aot
  • 🈯️ ARMv8 Without -O=-aot
root@DietPi:~# mono --version
Mono JIT compiler version 5.16.0.179 (tarball Thu Oct  4 12:05:24 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          yes(3.6.0svn-mono-/)
        GC:            sgen (concurrent by default)
root@DietPi:~# dietpi-services status

 DietPi-Services
─────────────────────────────────────────────────────
 Mode: status

[  OK  ] DietPi-Services | jackett      active (running) since Sun 2018-11-04 14:34:42 GMT; 1min 45s ago
[  OK  ] DietPi-Services | sonarr       active (running) since Sun 2018-11-04 14:34:42 GMT; 1min 45s ago
[  OK  ] DietPi-Services | radarr       active (running) since Sun 2018-11-04 14:34:42 GMT; 1min 45s ago
[  OK  ] DietPi-Services | lidarr       active (running) since Sun 2018-11-04 14:34:42 GMT; 1min 45s ago

@Fourdee
Copy link
Collaborator

Fourdee commented Nov 4, 2018

aot: https://www.mono-project.com/docs/advanced/runtime/docs/aot/

Sounds more beneficial than leaving it off?

@Fourdee
Copy link
Collaborator

Fourdee commented Nov 4, 2018

Interesting:
🈯️ -O=-aot
🈴 --aot

root@DietPi:~# /usr/bin/mono --aot -O=all /opt/jackett/JackettConsole.exe
Mono Ahead of Time compiler - compiling assembly /opt/jackett/JackettConsole.exe
AOTID E4A8AB7F-467D-A405-C2A6-BE94BA6BB23F
Code: 108772(78%) Info: 2896(2%) Ex Info: 8396(6%) Unwind Info: 3743(2%) Class Info: 5542(3%) PLT: 433(0%) GOT Info: 7908(5%) Offsets: 1829(1%) GOT: 4896
Compiled: 223/223 (100%), No GOT slots: 71 (31%), Direct calls: 0 (0%)
Executing the native assembler: "as"   -mfpu=vfp3 -o /tmp/mono_aot_ELtFYk.o /tmp/mono_aot_ELtFYk
Executing the native linker: gcc --shared -o /opt/jackett/JackettConsole.exe.so.tmp  /tmp/mono_aot_ELtFYk.o
Stripping the binary: "strip" --strip-symbol=\$a --strip-symbol=\$d /opt/jackett/JackettConsole.exe.so.tmp
JIT time: 191 ms, Generation time: 63 ms, Assembly+Link time: 263 ms.

Or, must pre-compile with --aot before launching?

https://www.mono-project.com/docs/advanced/aot/#aoting-all-the-system-libraries

Ah ok, so AOT pre-compiles libraries/programs which takes times, however, can improve load/run performance.
JIT compiles at run-time, slower loading but no cache (and potential issues) to worry about.

Regardless, lets leave this as is, Mono is delicate at the best of times.

@Fourdee
Copy link
Collaborator

Fourdee commented Nov 4, 2018

Ok, so can't replicate on ARMv7 ASUSTB, only difference is time of tarball

Mono JIT compiler version 5.16.0.179 (tarball Thu Oct 4 12:22:11 UTC 2018)
Mono JIT compiler version 5.16.0.179 (tarball Thu Oct  4 12:05:24 UTC 2018)

Test:

  • 🈯️ RPi 3

Unable to replicate this issue with fresh installations.

root@DietPi:~# systemctl status sonarr.service -l
● sonarr.service - Sonarr (NzbDrone) Daemon
   Loaded: loaded (/etc/systemd/system/sonarr.service; disabled; vendor preset:
enabled)
   Active: active (running) since Sun 2018-11-04 17:18:15 GMT; 1min 6
s ago
 Main PID: 9499 (mono)
   CGroup: /system.slice/sonarr.service
           └─9499 /usr/bin/mono /opt/NzbDrone/NzbDrone.exe -nobrowser -data=/mnt
/dietpi_userdata/sonarr

root@DietPi:~# mono --version
Mono JIT compiler version 5.16.0.179 (tarball Thu Oct  4 12:22:11 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          yes(3.6.0svn-mono-/)
        GC:            sgen (concurrent by default)

@Generator
Copy link

Tested on RPi3 with Radarr

Without -O=-aot

$ sudo -u radarr mono /opt/Radarr/Radarr.exe -nobrowser -data=/mnt/Storage/Dietpi/var/Radarr

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'NzbDrone.Console.ConsoleApp' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NzbDrone.Common.Instrumentation.NzbDroneLogger' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NLog.LogManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NLog.LogFactory' threw an exception. ---> System.OverflowException: TimeSpan overflowed because the duration is too long.
  at System.TimeSpan.Interval (System.Double value, System.Int32 scale) <0x74a03bb8 + 0x0010c> in <c3c5f4bb011a4af8b925b0d39ee12396#b6d93984cc5312a550b66bac10e075f9>:0
  at System.TimeSpan.FromSeconds (System.Double value) <0x74a03e88 + 0x0001b> in <c3c5f4bb011a4af8b925b0d39ee12396#b6d93984cc5312a550b66bac10e075f9>:0
  at NLog.LogFactory..cctor () [0x00000] in <a273cb27438940d6830e58cd57866c35>:0
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
  at NLog.LogManager..cctor () [0x00000] in <a273cb27438940d6830e58cd57866c35>:0
   --- End of inner exception stack trace ---
  at NzbDrone.Common.Instrumentation.NzbDroneLogger..cctor () [0x00005] in <445f1ed19d7d40fc8d1f35855cc618bc>:0
   --- End of inner exception stack trace ---
  at NzbDrone.Console.ConsoleApp..cctor () [0x00000] in <b6e6e83031db400582b8bc076d3bc359>:0
   --- End of inner exception stack trace ---
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'NzbDrone.Console.ConsoleApp' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NzbDrone.Common.Instrumentation.NzbDroneLogger' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NLog.LogManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'NLog.LogFactory' threw an exception. ---> System.OverflowException: TimeSpan overflowed because the duration is too long.
  at System.TimeSpan.Interval (System.Double value, System.Int32 scale) <0x74a03bb8 + 0x0010c> in <c3c5f4bb011a4af8b925b0d39ee12396#b6d93984cc5312a550b66bac10e075f9>:0
  at System.TimeSpan.FromSeconds (System.Double value) <0x74a03e88 + 0x0001b> in <c3c5f4bb011a4af8b925b0d39ee12396#b6d93984cc5312a550b66bac10e075f9>:0
  at NLog.LogFactory..cctor () [0x00000] in <a273cb27438940d6830e58cd57866c35>:0
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
  at NLog.LogManager..cctor () [0x00000] in <a273cb27438940d6830e58cd57866c35>:0
   --- End of inner exception stack trace ---
  at NzbDrone.Common.Instrumentation.NzbDroneLogger..cctor () [0x00005] in <445f1ed19d7d40fc8d1f35855cc618bc>:0
   --- End of inner exception stack trace ---
  at NzbDrone.Console.ConsoleApp..cctor () [0x00000] in <b6e6e83031db400582b8bc076d3bc359>:0
   --- End of inner exception stack trace ---

With -O=-aot

$ MONO_ENV_OPTIONS='-O=-aot'  sudo -u radarr mono /opt/Radarr/Radarr.exe -nobrowser -data=/mnt/Storage/Dietpi/var/Radarr
[Info] Bootstrap: Starting Radarr - /opt/Radarr/Radarr.exe - Version 0.2.0.1120
[Info] AppFolderInfo: Data directory is being overridden to [/mnt/Storage/Dietpi/var/Radarr]
[Info] Router: Application mode: Interactive
[Info] MigrationLogger: *** Migrating data source=/mnt/Storage/Dietpi/var/Radarr/nzbdrone.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal;pooling=True;version=3 ***
[Info] MigrationLogger: *** Migrating data source=/mnt/Storage/Dietpi/var/Radarr/logs.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal;pooling=True;version=3 ***
[Info] OwinHostController: Listening on the following URLs:
[Info] OwinHostController:   http://*:7878/radarr/
[Info] OwinHostController:   http://*:7878/
[Info] NancyBootstrapper: Starting NzbDrone API

Software version:
Mono

Mono JIT compiler version 5.16.0.179 (tarball Thu Oct  4 12:22:11 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          yes(3.6.0svn-mono-/)
        GC:            sgen (concurrent by default)

Dietpi

$ cat /DietPi/dietpi/.version
#!/bin/bash
G_DIETPI_VERSION_CORE=6
G_DIETPI_VERSION_SUB=17
G_DIETPI_VERSION_RC=12
G_GITBRANCH=master
G_GITOWNER=Fourdee

@Fourdee
Copy link
Collaborator

Fourdee commented Nov 11, 2018

@Generator

Thanks for the testing + report 👍

Ok, clearly we need to roll out -O=-aot. I'll make the change to all Mono applications + testing.

dietpi-software install 106 144 145 147

@Fourdee
Copy link
Collaborator

Fourdee commented Nov 11, 2018

Latest release link for Radarr/Lidarr not functional:
image

https://api.github.com/repos/Radarr/Radarr/releases/latest

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/repos/releases/#get-the-latest-release"
}

Latest release is always at the top of https://api.github.com/repos/Jackett/Jackett/releases. So we can use that for all.

Fourdee referenced this issue Nov 11, 2018
 - DietPi-Software | Mono applications (Radarr/Sonarr/Lidarr/Jackett): Rolled out "-O=-aot" (ahead of time optimzation) to all applications, which resolves a known external bug with recent Mono update. Many thanks to @Generator for testing and confirming this issue: https://github.com/Fourdee/DietPi/issues/2219#issuecomment-437594645

- DietPi-Software | Radarr/Lidarr: Resolved failed installation due to api URL change: https://github.com/Fourdee/DietPi/issues/2219#issuecomment-437683004

+ RC beta up
@Fourdee
Copy link
Collaborator

Fourdee commented Nov 11, 2018

Retest:

dietpi-software install 106 144 145 147
  • 🈯️ ARMv7
  • 🈯️ ARMv8

@Fourdee
Copy link
Collaborator

Fourdee commented Nov 11, 2018

Fixed in Beta:

Completed.

@Fourdee Fourdee closed this as completed Nov 11, 2018
@MichaIng
Copy link
Owner Author

@Fourdee
Whoopsie, my fault to not test this for all. /latest is not yet code within release, I added this some days ago with the jackett reinstall fix I think. Just found that to be handy and though it is part of the GitHub API to always work, whenever a release is available. Seems not, maybe the maintainer needs to manually mark a release as latest first or such 🤔. But yeah, grep -m1 should be safe, since latest is always on the top 👍. I planned to use this in more cases where we currently download a certain release (and need to regularly update our URL for this). We have no "chance" to test new releases then before adding to our code, on the other hand there will be less user requests to update to current version. Also we download latest already in most other cases, where possible, via master branch and such.

@msdos
Copy link

msdos commented Nov 20, 2018

I'm using 6.17.2 and all applications that use Mono are broken.

@msdos
Copy link

msdos commented Nov 20, 2018

I used the workaround proposed here (and https://github.com/Fourdee/DietPi/pull/2235/files): edited all /etc/systemd service files related to sonarr, lidarr, jackett and radarr to call mono using -O=-aot.

MichaIng added a commit that referenced this issue Apr 21, 2021
+ DietPi-Software | Sonarr: Migrate to v3
+ DietPi-Software | Mono: Remove obsolete "-O=-aot" from Mono calls, which was a workaround that has been fixed in the meantime: #2219
+ DietPi-Software | Complement and align Arr service hardenings
MichaIng added a commit that referenced this issue Apr 21, 2021
+ DietPi-Software | Sonarr: Migrate to v3
+ DietPi-Software | Mono: Remove obsolete "-O=-aot" from Mono calls, which was a workaround that has been fixed in the meantime: #2219
+ DietPi-Software | Complement and align Arr service hardenings. PrivateTmp cannot be used, as this would break DietPi-Arr_to_RAM.
+ DietPi-Patches | Inform user about possible Sonarr v2 => v3 upgrade
+ DietPi-Arr_to_RAM | Add support for Sonarr v3 and Radarr v3
+ DietPi-Arr_to_RAM | On first link to RAM, create a script in the programs data dir to update the linked database backups, as v3 do not support arguments to pass to custom scripts anymore and do not allow to start scripts from within /boot.
+ DietPi-Software | Sonarr: Install mediainfo, which is suggested by the package but no strict dependency. Align with Radarr and Lidarr.
+ DietPi-Software | Radarr: Remove Radarr v2 PID file and database backups from DietPi-Arr_to_RAM, which can be left overs
+ DietPi-Arr_to_RAM | Use safer approach to create database backups: The -shm and -wal files do sometimes not exist, e.g. when the connection is closed temporarily. In theory the should never exist when the program is not running, but in practice it does at least with Sonarr and Lidarr, which obviously do not close connections gracefully or use certain SQLite flags to keep those files intentionally. However, havoc can happen when those files do not exist while the database is linked to RAM or stored back to disk: In the first case, if the program then crashes, up-to-date -shm + -wal files will be mixed with a backup database file, in the second case, the -shm and -wal symlinks will stay on disk, breaking program start as the RAM dir is removed. Especially in combination with the automatic backup restoring, mixing of old and new files can happen, corrupting the database. At least when linking to RAM and for backup creation, SQLite is used now to read and store the database to the backup location, which includes -shm and -wal, so that a single consistent database file is present for the program to start with.
+ DietPi-Patches | Remove obsolete DietPi-Arr_to_RAM backup files, as now "sqlite3 db .save" is used to store a single db file as backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External bug 🐞 For bugs which are not caused by DietPi. Information ℹ️ Solution available 🥂 Definite solution has been done Unable to replicate ☕ Via Forum
Projects
None yet
Development

No branches or pull requests

4 participants