[Samsung Galaxy S10 ROMs, Kernels, Recoveries, & Ot] dcaondyer:
No, I didn't hide Magisk with another app, because "Basic Integrity" was sufficient for me. However after this problem I had reset the /data partition for the umpteenth time (ignoring /data/media) from TWRP and without even switching to Odin the phone started booting again (as usual). It appears that there is something in the /data partition that changes the boot sequence and freezes it. Or after some error some configuration file is modified which is restored only after a reset of the /data partition.

The problem occurs whether /data/media is deleted or kept. From what I know, it came with Android 12 and does not depend on the kernel (in fact yesterday it presented itself to me for the first time with Cruel Kernel, which until now had seemed immune, and all the others kernels have the same problem).

This last time the problem arose when I inadvertently started the phone (I thought it was charged) and it was only at 0%. It stayed on for a few seconds, and I didn't have time to turn it off before it died. The problem then reappeared. Another explanation for the cause of the problem could be that when there is a crash or power failure, the phone does not shut down "well" and maybe some configuration or perhaps init file is altered. The weird thing is that only by deleting the data from /data does it resume booting. The presence of the /data/adb folder seems indifferent and whether Magisk is active or deactivated does not change the situation.

I would like to try to understand what exactly TWRP does during a factory reset to see if in addition to deleting /data ignoring /data/media it resets some system configuration files: the only solution known so far is the reset with TWRP. But not knowing the TWRP code base I really struggle to find the part interested in the factory reset.

Update:

I've tried to get all available kmsg, but I can't find any errors. Instead, the last time the problem with the stock kernel appeared (about 10 months ago) I noticed that the cause of the shutdown seemed to be a power problem: the device was unable to start a certain service for checking the battery and then entered a certain "low_energy_mode" which due to incorrect SELinux permissions did not start and the boot ended with a reboot. However beyond this I don't remember anything else and I can't find the old log files (first_kmsg and last_kmsg) that I had taken from /proc.

Anyway I got these two magisk log files from /cache that might help.

Second Update:

I finally managed to obtain different last_kmsg, but I haven't traced down the problem. (I'll attach 2 of them)

However I've noticed that /sys/firmware/devicetree/base/firmware/android/fstab/system/status is marked as "disabled". Someone with a working phone could verify this flag (when the partition is working it appear as "okay")?

Also, I've noticed that /fstab.exynos9820 and /vendor/etc/fstab.exynos9820 reported different settings (userdata have "ice" file encryption enabled in /fstab.exynos9820, while the same line in /vendor/etc/fstab.exynos9820 is commented out: this seems normal, for the use of multi-disabler). In either files /vendor and /system lines are commented out. (I will attach the two different partition table)

In the end I've obtained this description of the kernel log:

init: DM_DEV_STATUS failed for system: No such device or address: These lines indicate that there are issues with device mapper (DM) device status for a component called "system" and "vroot." It's reporting that it can't find the specified devices or addresses.

[libfs_mgr]dt_fstab: Skip disabled entry for partition system: These lines suggest that the system is skipping the initialization of a partition called "system" because it is marked as disabled in the device tree (dt_fstab).

Top-level directory needs encryption action...: These lines indicate that certain top-level directories need encryption actions, such as creating directories with specific permissions and encryption requirements.

init: cannot execv('/system/bin/sh'). See the 'Debugging init' section...: This message suggests that there is a permission issue preventing the system from executing the /system/bin/sh shell.

[softdog] !@Success to disable, do_restorecon: Messages related to the softdog process, which is associated with software watchdog functionality.

watchdog: watchdog1: watchdog did not stop!: Indicates an issue with a watchdog process not stopping correctly.

Service 'exec 13 (/system/bin/sh -c profman ... and related messages: These lines pertain to a service execution attempt that seems to be failing due to an issue with executing a shell command.

libprocessgroup: Successfully killed process cgroup uid 1000 pid 5229 in 0ms: This message indicates the successful termination of a process with a specific process ID (pid).

It seems like there are various issues and warnings related to the initialization of different system components and services. To diagnose and resolve these problems, you may need to further investigate each error message individually. Start by addressing the issues related to missing devices or addresses, permission problems, and service failures. It may also be helpful to check the system's configuration files and permissions.

All the problems seem related to the /system partition, and so I have thought that maybe if /system partition return to be "okay" and not "disabled" the system turn on.

I've removed the two magisk log files because the only intersting lines are these:

08-26 16:19:12.953 5220 5222 E : umount2 /system/bin/appwidget failed with 22: Invalid argument

08-26 16:19:12.959 5220 5222 E : umount2 /system/bin/bu failed with 22: Invalid argument

but I don't know what executables are these.

Update 3:

Finally I managed to resolve part of the problem. However I haven't understood why the device restarted to work. The only things I lose are the datas of every single app in private storage (/data/data), but all the apps themselves are already installed. Maybe if I had found where is the cryptographic key that manages the random codes in /data/app/*random_code*/com.app.name/base.apk and I wouldn't have deleted this, app datas could be restored.

To fix the problem I've deleted all directory under /data except /data/adb /data/data /data/app /data/misc_ce/0 /data/misc_de/0 /data/system_de/0 and /data/media. All phone and app settings are gone, but them could easily be restored from a backup.

All magisk modules are correctly working. The only thing I've noticed is they were disabled (with a simple reboot they restart to work) at first boot time.