Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
03746 Core Major Always Feb 23, 2010, 19:12 Feb 28, 2010, 13:45
Tester pingbak View Status Public Platform SDLMAME
Assigned To couriersud Resolution Fixed OS MacOS X
Status [?] Resolved Driver
Version 0.136u3 Fixed in Version 0.136u4 Build Debug
Fixed in Git Commit Github Pull Request #
Summary 03746: [debug] Overloaded C++ operator new/operator delete is too restrictive
Description 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.
Steps To Reproduce
Additional Information Another good reason to rethink global operator new/delete: delete has different declarations on different versions of gcc, viz:

    operator delete(void *);

vs.

    operator delete(void *) throw();

The declarations are not strictly the same.
Github Commit
Flags Debug build specific
Regression Version
Affected Sets / Systems
Attached Files
 
Relationships
There are no relationship linked to this issue.
Notes
1
User avatar
No.05794
couriersud
Developer
Feb 28, 2010, 13:45
Global delete operator is now declared as "inline" in emualloc.h. Now only files including emualloc will make use of this version.
Before, delete was compiled into a global symbol in the object file and during linking used instead of the "standard" one. This was causing the abort since MAME "delete" would be called on objects declared in system libraries. This does not happen with the "inline" version.

However, yes, global overrides may turn into a nightmare. In a strictly controlled environment like MAME this is less likely, though.