During a migration project I stumbled over invalid data and mariadb server crashes after changing charset and collation of tables.
I managed to boil the issue down to apparent InnoDB index issues in combination with modifying collations on existing tables. The issue is reproducible on different servers and appears in 10.4.19, 10.5.13 and 10.6.5. It does not appear in 10.2.38 and 10.3.29.
All that is required to provoke the issue is adding a one-column table with a key, adding some (partially crafted, but very basic) rows and then converting the collation (e.g. from utf8mb4_general_ci to utf8mb4_unicode_ci).
Afterwards the table/index is broken and mariadb crashes if CHECK TABLE is issued for that table. I attached an .sql file which - if passed to the server - reliably causes a crash. I also added a log excerpt for that crash.
The table/index can be repaired manually by issuing an OPTIMIZE TABLE or ALTER TABLE <table> ENGINE=INNODB.
In our actual environment the issue also manifested in a way that some data just would not be retrieved when selected by the indexed column (and index errors were shown in the log). I believe that part has the same root cause, so I'm not adding any further info.
Do let me know if you need further information.