This problem was solved by dhylands but making a separate post for someone to find the solution easier.
PROBLEM:
Garbage collect destroying memory that has a valid chain of pointers starting with a root pointer.
SOLUTION:
dhylands wrote: ↑Mon Apr 16, 2018 4:11 pmOne possible "chain" that I don't believe that the gc follows is if you have a heap object pointing back into non-heap (i.e. static globals) and those static globals have a pointer into the heap. In that case, the gc wouldn't see the pointer from the static data. The gc only follows pointers within the heap itself.
Since you're building things dynamically, and your module object is declared statically, this might be the cause.