anselmschueler
because I have forgotten my PIN
You can boot recovery and wipe the device. It will act as a fresh install. Stock OS has an anti-theft feature where it stores the Google account in the secure element's factory reset protection data block and requires logging into it to proceed through the setup wizard, but this is an anti-theft feature rather than a security feature and we don't include an equivalent at the moment. It would result in bricked devices if it didn't have an equivalent to Google account recovery processes, wasting more money simply to make phones worth less money to thieves which isn't very useful at a small scale.
or it is corrupted irrevocably due to some bug
Wiping data via recovery will resolve a bug causing a crash on boot. The firmware and OS is bit-for-bit identical across every installation and verified cryptographically. The firmware and core OS images are very small, and the high level OS images have forward error correction metadata. If verification fails, it will correct corruption and try verifying again, so random data corruption/loss on the SSD won't cause it to get bricked in most cases.
Updates are installed to inactive firmware/OS partitions. After it's installed, the install attempt gets verified based on the hashes of the images written to the inactive partitions. If it passes, then it gets activated. On next boot, it loads the new OS version. When it reaches the point it mounts the persistent state (encrypted /data partition), it mounts it with persistence disabled, which is an f2fs feature based on it being a log structured filesystem which only appends changes and then later checkpoints (persists) them and later garbage collects the stale data. If at any point booting fails before it reaches the homescreen and finalizes it, it will switch back to the previous set of firmware/OS partitions. Once it succeeds, it disables rollback, updates firmware and OS anti-rollback protection to prevent downgrade attacks at the verified boot level and enables data persistence for the data partition.
If you're concerned about the OS somehow not being able to boot despite all of this, you can still have it locked with the OEM unlocking not disabled so that you can still unlock it in the firmware fastboot mode, which will irrecoverably wipe all of the data similar to other ways to do a factory reset (wipe).