There is a potential collision with the DynamicMessageFactory since it is statically scoped. If a new object is created with a different proto that has the same name as another, the factory strips it from the cache (as far as I can tell). However, descriptors generated from it still live within a pool, which tries to clean up, but now has invalid pointers.
By making the factory locally scoped, other encoders cannot affect this, which seems to stop the segfaults.
Additionally, had to make it so it was stack allocated rather than heap allocated, which required me to change the constructor slightly.
There is a potential collision with the DynamicMessageFactory since it is statically scoped. If a new object is created with a different proto that has the same name as another, the factory strips it from the cache (as far as I can tell). However, descriptors generated from it still live within a pool, which tries to clean up, but now has invalid pointers.
By making the factory locally scoped, other encoders cannot affect this, which seems to stop the segfaults.
Additionally, had to make it so it was stack allocated rather than heap allocated, which required me to change the constructor slightly.