We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 295 - Reinitializing SDL_mixer crashes on something to do with midi
Summary: Reinitializing SDL_mixer crashes on something to do with midi
Status: RESOLVED DUPLICATE of bug 274
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-07 11:35 UTC by Facundo Dominguez
Modified: 2006-11-28 14:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Facundo Dominguez 2006-08-07 11:35:55 UTC
Hello:
   I call Mix_OpenAudio.
   Then call Mix_ColseAudio().
   Then call Mix_OpenAudio again (then it crashes).

   This is with last versions of SDL (1.2.11) and SDL_mixer (1.2.7) on linux Fedora Core 4 and Windows.
   I recompile SDL_mixer without midi support and then the program ran ok.

   I give you here both the program and the memory report of valgrind (Line 133 of main is the second call to Mix_OpenAudio).

   This bug may have something to do with bug 274.

=========== Crashing PROGRAM ===============


int main(){

  // up SDL
  if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) != 0) {
    cerr<<"Unable to initialize SDL: "<<SDL_GetError()<<"\n";
    exit(1);
  }
  SDL_EnableUNICODE(1);

  // up the video
  SDL_Surface * screen = SDL_SetVideoMode(640, 480, 8, SDL_HWSURFACE | SDL_DOUBLEBUF);
  if (screen == NULL) {
    fprintf(stderr,"Unable to set video mode: %s\n", SDL_GetError());
    exit(1);
  }

  // up the audio
  if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS,int(pow(2,9)))) {
    cleanUp(VIDEO);
    cerr<<"Could not initialize audio system: "<<Mix_GetError()<<"\n";
    exit(1);
  };
  Mix_CloseAudio();
  if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) != 0) {
    cerr<<"Unable to initialize SDL: "<<SDL_GetError()<<"\n";
    exit(1);
  }
  if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS,int(pow(2,9)))) {
    cleanUp(VIDEO);
    cerr<<"Could not initialize audio system: "<<Mix_GetError()<<"\n";
    exit(1);
  };

  return 0;
}


==18245== Memcheck, a memory error detector for x86-linux.
==18245== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==18245== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==18245== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==18245== For more details, rerun with: -v
==18245==
==18245== Invalid read of size 4
==18245==    at 0xD6FE69: open_file (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD80EEC: read_config_file (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD81F91: Timidity_Init (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD4C594: open_music (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD4986C: Mix_OpenAudio (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0x804EBE2: main (sjsound.cpp:133)
==18245==  Address 0x1BBACE10 is 0 bytes inside a block of size 8 free'd
==18245==    at 0x1B909743: free (vg_replace_malloc.c:152)
==18245==    by 0xD70228: free_pathlist (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD7CDDB: Timidity_Close (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)==18245==    by 0xD4DBEA: close_music (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD4B1EE: Mix_CloseAudio (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)==18245==    by 0x804EB66: main (sjsound.cpp:128)
==18245==
==18245== Invalid read of size 1
==18245==    at 0xD6FE79: open_file (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD80EEC: read_config_file (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD81F91: Timidity_Init (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD4C594: open_music (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD4986C: Mix_OpenAudio (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0x804EBE2: main (sjsound.cpp:133)
==18245==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==18245==
==18245== Process terminating with default action of signal 11 (SIGSEGV)
==18245==  Access not within mapped region at address 0x0
==18245==    at 0xD6FE79: open_file (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD80EEC: read_config_file (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD81F91: Timidity_Init (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD4C594: open_music (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0xD4986C: Mix_OpenAudio (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==18245==    by 0x804EBE2: main (sjsound.cpp:133)
==18245==
==18245== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 64 from 3)
==18245== malloc/free: in use at exit: 1371611 bytes in 2920 blocks.
==18245== malloc/free: 8081 allocs, 5161 frees, 1592297 bytes allocated.
==18245== For counts of detected errors, rerun with: -v
==18245== searching for pointers to 2920 not-freed blocks.
==18245== checked 12428256 bytes.
Comment 1 Patrice Mandin 2006-11-28 14:20:37 UTC

*** This bug has been marked as a duplicate of 274 ***