|システムコア||中||解決済み||修正済み||2010-02-24 04:12||2010-02-28 22:45|
|概 要||オーバーロードしたoperator newとoperator delete動作が厳しすぎてMacOSでクラッシュする。|
|詳 細||This isn't hard to reproduce, at least on the Mac OS X platform. When compiled with MAME_DEBUG set, sdlmame will crash. The problem is that this is likely not specific to sdlmame, but to the design decision to overload operator new and operator delete globally and to abort if the deleted pointer is not found in the tracked set of pointers.|
Basically, this design needs to be more permissive -- it should not abort on a perceived allocation error. Complain about it, sure. Abort, not a good choice. The reason is that there are long standing bugs in every vendor's system libraries that wont be corrected. A good example of this is libGLUT (GL utilities library). Other examples abound, such as the common mistake of calling 'delete' instead of 'delete ' (which might be happening in this case, but can't tell for sure.)
I've got some experience with writing debugging malloc and overloading operator new/delete; I was an early contributor to and tester of Gray Watson's "dmalloc" library. "dmalloc" is still used by many to find allocation problems. 'valgrind' on the Linux platform is also a good way to locate allocation issues.
Customized new/delete that passes extra parameters for source file and line is reasonable because that would only affect mame source where it is used. Overloading the global versions is a maintenance headache.
|追加情報||Another good reason to rethink global operator new/delete: delete has different declarations on different versions of gcc, viz:|
operator delete(void *);
operator delete(void *) throw();
The declarations are not strictly the same.