Archived:Throwing any object from 'new' operator on the ARMV5 platform causes a crash (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1 and FP2
S60 3rd Edition FP2
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Created: User:Technical writer 1 (12 Jun 2008)
Last edited: hamishwillee (19 Jun 2012)


Throwing bad_alloc or any object from new on the ARMV5 platform causes a crash. The problem occurs even if the user throws an object from within an overloaded new operator.

The new operators with the following signatures are affected:

 void *operator new(unsigned int aSize);
 void *operator new[](unsigned int aSize);

How to reproduce

The following code snippet is an example that depicts the problem:

class Dummy
void *operator new(unsigned int aSize)
void* __y = malloc(aSize);
// try to simulate a bad alloc
if (__y == 0)
throw Dummy(); // this will result in a crash
return __y;


To implement a user-owned overloaded version of new, it must be implemented as class specific. The other way this can be achieved is by defining new as follows:

void* operator new(size_t s, newarg) throw (std::bad_alloc)

and invoking it as:

Myclass* my = new (S60) Myclass()
This page was last modified on 19 June 2012, at 10:57.
32 page views in the last 30 days.