CleanupStack::PushL(aActiveScheduler) panics EUser CBase 66

Login to reply to this topic.
Wed, 2008-02-13 08:22
Joined: 2006-09-26
Forum posts: 9

Hi,

The following code panics EUser CBase 66 in my exe

     CTrapCleanup* cleanup = CTrapCleanup::New();
     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
     CleanupStack::PushL(scheduler);  // push scheduler

      //..................................

     CleanupStack::PopAndDestroy(scheduler);  // pop scheduler       
     delete cleanup;

The panic document is very tricky to understand. Can anybody explain why my PushL panics. If I comment this line and try to call NewL of other class which contains PushL also panics. It shows that my CleanupStack is not instantiated properly or anything else...

Hint: Any call to CleanupStack::PushL panics (E32User CBase 66) in my exe code.

Please help me to figure out this...

Thanks & regards


Best Regards
Symadept


Wed, 2008-02-13 11:27
Joined: 2003-12-05
Forum posts: 586
Re: CleanupStack::PushL(aActiveScheduler) panics EUser CBase 66

Have you looked at the panic description from the SDK help?


This panic is raised if an attempt is being made to insert a cleanup item into a position on the cleanup stack reserved for marking the current TRAP nest level. In practice this error occurs if the call to CleanupStack::PushL() happens when there has been no call to TRAP().

Wed, 2008-02-13 12:26
Joined: 2003-09-29
Forum posts: 32
Re: CleanupStack::PushL(aActiveScheduler) panics EUser CBase 66

In addition to generating panic the code in the original posting is not leave safe. This is the common pattern that is being used in EXEs:

static void ThreadFunctionL()
    {
    CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
    CleanupStack::PushL(activeScheduler);
    CActiveScheduler::Install(activeScheduler);
   
    // ....................................

    CleanupStack::PopAndDestroy(activeScheduler);
    }

TInt E32Main()
    {
    CTrapCleanup* cleanup = CTrapCleanup::New();
    TInt result = KErrNoMemory;
    if (cleanup)
        {
        TRAP(result, ThreadFunctionL());
        delete cleanup;
        }
    return result;
    }


Jari

  • Login to reply to this topic.