Menu

#22 Error in mt32emu-qt free(): invalid pointer

closed
Serg M
None
v1.5.0
1
2015-11-22
2015-11-22
Pickle136
No

Im using munt with dosbox, when i was terminating dosbox mt32emu-qt would crash with the invalid pointer error.

Reviewing the source file for synth.cpp its clear the Synth class is trying to decontruct 3 instances. The error occurs on the 3rd. Its clear the delete operations are trying to free pointers that have garbage data for pointer values.

This can be fixed by initializing all the pointers to NULL and checking for NULL in the decontructor.

Synth::Synth
patchTempMemoryRegion = NULL;
rhythmTempMemoryRegion = NULL;
timbreTempMemoryRegion = NULL;
patchesMemoryRegion = NULL;
timbresMemoryRegion = NULL;
systemMemoryRegion = NULL;
displayMemoryRegion = NULL;
resetMemoryRegion = NULL;
paddedTimbreMaxTable = NULL;

void Synth::deleteMemoryRegions() {
if (patchTempMemoryRegion != NULL ) {
delete patchTempMemoryRegion;
patchTempMemoryRegion = NULL;
}
if (rhythmTempMemoryRegion != NULL ) {
delete rhythmTempMemoryRegion;
rhythmTempMemoryRegion = NULL;
}
if (timbreTempMemoryRegion != NULL ) {
delete timbreTempMemoryRegion;
timbreTempMemoryRegion = NULL;
}
if (patchesMemoryRegion != NULL ) {
delete patchesMemoryRegion;
patchesMemoryRegion = NULL;
}
if (timbresMemoryRegion != NULL ) {
delete timbresMemoryRegion;
timbresMemoryRegion = NULL;
}
if (systemMemoryRegion != NULL ) {
delete systemMemoryRegion;
systemMemoryRegion = NULL;
}
if (displayMemoryRegion != NULL ) {
delete displayMemoryRegion;
displayMemoryRegion = NULL;
}
if (resetMemoryRegion != NULL ) {
delete resetMemoryRegion;
resetMemoryRegion = NULL;
}
if (paddedTimbreMaxTable != NULL ) {
delete[] paddedTimbreMaxTable;
paddedTimbreMaxTable = NULL;
}
}

Edit: Attached the full call trace

This is also with the dosbox svn with the patch applied and svn munt. All compiled and running on 64 bit linux.

1 Attachments

Discussion

  • Pickle136

    Pickle136 - 2015-11-22
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -54,4 +54,8 @@
         }
     }
    
    +Edit: Attached the full call trace
    +
    +This is also with the dosbox svn with the patch applied and svn munt. All compiled and running on 64 bit linux.
    +
    
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -0,0 +1 @@
    +mt32_trace (2.0 kB; application/octet-stream)
    
     
  • Serg M

    Serg M - 2015-11-22

    Thanks for reporting this.

     
  • Serg M

    Serg M - 2015-11-22
    • status: open --> accepted
    • assigned_to: Serg M
     
  • Serg M

    Serg M - 2015-11-22
    • status: accepted --> closed
     
  • Serg M

    Serg M - 2015-11-22

    Looks fixed as of commit d557f65ec8d

     

Log in to post a comment.

MongoDB Logo MongoDB