When setting the maximum voices limit Engine::pDimRegionPool[0] and Engine::pDimRegionPool[1] are deleted (engines/gig/Engine.cpp:2134) but if there are already sampler channels connected to audio devices they continue to use the pointers to the memory now freed (pDimRegionsInUse uses the freed pools - engines/gig/EngineChannel.cpp:298)
Attached patch. Note: to reproduce this bug load instrument to a sampler channel, change the maximum voice limit and start playing notes.
Created attachment 47 [details] 118.patch.bz2
The patch works fine for me, but I think the ClearDimRegionsInUse part is unnecessary.
(In reply to comment #3) > The patch works fine for me, but I think the ClearDimRegionsInUse part is > unnecessary. If you set the maximum voice limit while there are active streams pDimRegionsInUse will not be empty and, if you delete pDimRegionPool before clearing/deleting pDimRegionsInUse, in its destructor pDimRegionsInUse will try to push back the elements in the list to pDimRegionPool, which is already deleted. So in this case a memory corruption will occur. See bug #120 before testing this scenario.
(In reply to comment #4) Ah, you're right of course. This is the part I missed when I looked at the code before: > its destructor pDimRegionsInUse will try > to push back the elements in the list to pDimRegionPool
Applied the patch.