Bug 118 - Orphaned pointers when setting maximum voices limit
Summary: Orphaned pointers when setting maximum voices limit
Status: CLOSED FIXED
Alias: None
Product: LinuxSampler
Classification: Unclassified
Component: gig::Engine (show other bugs)
Version: SVN Trunk
Hardware: All All
: P2 critical
Assignee: Christian Schoenebeck
URL:
Depends on:
Blocks:
 
Reported: 2009-02-12 14:26 CET by Grigor Iliev
Modified: 2009-03-02 15:21 CET (History)
1 user (show)

See Also:


Attachments
118.patch.bz2 (959 bytes, application/x-bzip)
2009-02-18 15:29 CET, Grigor Iliev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Grigor Iliev 2009-02-12 14:26:14 CET
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)
Comment 1 Grigor Iliev 2009-02-18 15:27:08 CET
Attached patch.

Note: to reproduce this bug load instrument to a sampler channel, change the
maximum voice limit and start playing notes.
Comment 2 Grigor Iliev 2009-02-18 15:29:30 CET
Created attachment 47 [details]
118.patch.bz2
Comment 3 Andreas Persson 2009-02-21 14:42:39 CET
The patch works fine for me, but I think the ClearDimRegionsInUse part is
unnecessary.
Comment 4 Grigor Iliev 2009-02-21 17:37:50 CET
(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.
Comment 5 Andreas Persson 2009-02-21 17:53:37 CET
(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
Comment 6 Grigor Iliev 2009-02-21 18:11:57 CET
Applied the patch.