Hi Enzo,
This is both a bug and a limitation of the platform. Thank you for discovering it. The problem is that you have ProcessContainer icons in your workspace. ProcessContainer is an internal process. Internal processes are those defined by the PixInsight Core application. There are just two of them, the other one is Script.
ProcessContainer is a very special process. It represents one of the fundamental pillars of PixInsight: processing histories. Currently a ProcessContainer cannot be instantiated from a module using the Process, ProcessIntance and ProcessParameter classes, partly because some required API routines have not been implemented for this process, and mainly because there are no abstract resources in PCL to formalize a processing history and its associated functionality. These will be implemented in future versions of the PixInsight Core application and PCL, along with more powerful and flexible implementations of the Process, ProcessIntance, ProcessParameter and ProcessInterface classes.
Unfortunately, the current implementation of ProcessInstance::IconsByProcessId() needs to instantiate the processes encapsulated by the existing icons in order to gather required information about them. If you have ProcessContainer icons, a crash is guaranteed if you call this static member function. This should not happen, of course, so it is obviously a bug.
From the code you've posted, it seems you are trying to instantiate existing processes to perform some sort of automation. If this is what you want to do, I strongly recommend you implement your task in JavaScript. The PJSR does not have any of the limitations described above, and is the best way to execute and control automated processes in PixInsight.