According to the docs and comment inside module_copy_string_contents it should always produce a valid utf-8 string that can be used in dynamic modules, but it seems it's not always the case. I encountered an emacs crash when using emacs-module-rs because it always expects a valid utf-8 for strings. To reproduce you can call:
(some-function-from-dynamic-library (encode-coding-string (f-read-text "wg-private-pc.age") 'utf-8 t))