×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    KERN-EXEC 3 panic comes when click on 'Exit' option.

    My Code is

    Appui.cpp
    ---------

    Code:
    void CHelloWorldBasicAppUi::ConstructL()
        {
        BaseConstructL();
        iAppView = CHelloWorldBasicAppView::NewL( ClientRect() );
        iSplit = CSplit::NewL();
        }
    
    CHelloWorldBasicAppUi::~CHelloWorldBasicAppUi()
        {
        
        if(iSplit) // Just in case
           {
           delete iSplit;
           iSplit = NULL;
           }
        if ( iAppView )
            {
            delete iAppView;
            iAppView = NULL;
            }
        }
    
    void CHelloWorldBasicAppUi::HandleCommandL( TInt aCommand )
        {
        switch( aCommand )
            {
            case EEikCmdExit:
            case EAknSoftkeyExit:
                Exit();
                break;
            case ESPlitString:
                    	{
                    	_LIT(KStr, "ABCjjjDEFjjjGHI");
                    	_LIT(KSplit, "jjj");
                    	CDesCArrayFlat *splitArr = new (ELeave) CDesCArrayFlat(1);
                     	splitArr = iSplit->SplitStringL(KStr,KSplit);
                    	delete splitArr;
                    	splitArr = NULL;
           	
                    	}
                    	break;
            default:
                Panic( EHelloWorldBasicUi );
                break;
            }
        }
    Split.cpp
    ---------

    Code:
    CSplit::~CSplit()
        {
        //Close();  // Just in case, if the user does not close this explicitely
        //iFsSession.Close();
        if (iGetSplitDataArr)
        	{
        	delete iGetSplitDataArr;
        	iGetSplitDataArr = NULL;
        	}
        }
    
    void CSplit::ConstructL()
        {
        iGetSplitDataArr =  new (ELeave) CDesCArrayFlat(5);
        }
    void CSplit::Close()
    	{
    	if (iGetSplitDataArr)
    	    	{
    	    	delete iGetSplitDataArr;
    	    	iGetSplitDataArr = NULL;
    	    	}
    	}
    CDesCArrayFlat* CSplit::SplitStringL(const TDesC& aData, const TDesC& aSplitString) 
    	{
    		return iGetSplitDataArr;
    	}
    Split.h
    --------
    Code:
    class CSplit : public CBase
    	{
    	CDesCArrayFlat* SplitStringL(const TDesC& aData, const TDesC& aSplitString);
    public: // Member data
    	CDesCArrayFlat* iGetSplitDataArr;
    	          
        };
    Please help me why this error comes at exit application time???

    Thank You for see my query

  2. #2
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by SymbianTH View Post
    My Code is

    Appui.cpp
    ---------

    Code:
    void CHelloWorldBasicAppUi::ConstructL()
        {
        BaseConstructL();
        iAppView = CHelloWorldBasicAppView::NewL( ClientRect() );
        iSplit = CSplit::NewL();
        }
    
    CHelloWorldBasicAppUi::~CHelloWorldBasicAppUi()
        {
        
        if(iSplit) // Just in case
           {
           delete iSplit;
           iSplit = NULL;
           }
        if ( iAppView )
            {
            delete iAppView;
            iAppView = NULL;
            }
        }
    
    void CHelloWorldBasicAppUi::HandleCommandL( TInt aCommand )
        {
        switch( aCommand )
            {
            case EEikCmdExit:
            case EAknSoftkeyExit:
                Exit();
                break;
            case ESPlitString:
                    	{
                    	_LIT(KStr, "ABCjjjDEFjjjGHI");
                    	_LIT(KSplit, "jjj");
                    	CDesCArrayFlat *splitArr = new (ELeave) CDesCArrayFlat(1);
                     	splitArr = iSplit->SplitStringL(KStr,KSplit);
                    	delete splitArr;
                    	splitArr = NULL;
           	
                    	}
                    	break;
            default:
                Panic( EHelloWorldBasicUi );
                break;
            }
        }
    Split.cpp
    ---------

    Code:
    CSplit::~CSplit()
        {
        //Close();  // Just in case, if the user does not close this explicitely
        //iFsSession.Close();
        if (iGetSplitDataArr)
        	{
        	delete iGetSplitDataArr;
        	iGetSplitDataArr = NULL;
        	}
        }
    
    void CSplit::ConstructL()
        {
        iGetSplitDataArr =  new (ELeave) CDesCArrayFlat(5);
        }
    void CSplit::Close()
    	{
    	if (iGetSplitDataArr)
    	    	{
    	    	delete iGetSplitDataArr;
    	    	iGetSplitDataArr = NULL;
    	    	}
    	}
    CDesCArrayFlat* CSplit::SplitStringL(const TDesC& aData, const TDesC& aSplitString) 
    	{
    		return iGetSplitDataArr;
    	}
    Split.h
    --------
    Code:
    class CSplit : public CBase
    	{
    	CDesCArrayFlat* SplitStringL(const TDesC& aData, const TDesC& aSplitString);
    public: // Member data
    	CDesCArrayFlat* iGetSplitDataArr;
    	          
        };
    Please help me why this error comes at exit application time???

    Thank You for see my query

    How you called CSplit::ConstructL() ???

    Also put breakpoint in destructor of CHelloWorldBasicAppUi and check which line cause problem.

  3. #3
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    In "AppUi.cpp"

    ConstructL() contains isplit class's instance.
    {
    iSplit = CSplit::NewL();
    }

    In Split.cpp
    -------------

    CSplit* CSplit::NewL()
    {
    CSplit* tmp = new (ELeave)CSplit();
    CleanupStack::PushL(tmp);
    tmp->ConstructL();
    CleanupStack::Pop();
    return tmp;
    }

    when i debug code at that time panic come at "delete iGetSplitDataArr;" line execution.

    CSplit::~CSplit()
    {
    if (iGetSplitDataArr)
    {
    delete iGetSplitDataArr;
    iGetSplitDataArr = NULL;
    }
    }

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,336

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Your function SplitStringL is transferring the ownership of the array to the caller of that function. Now as you are already deleting it in the following code, you should not delete it again from the CSplit destructor:

    Code:
    CDesCArrayFlat *splitArr = new (ELeave) CDesCArrayFlat(1);
    splitArr = iSplit->SplitStringL(KStr,KSplit);
    delete splitArr;
    splitArr = NULL;
    So remove deletion of iGetSplitDataArr from the CSplit destructor.

    Code:
    CSplit::~CSplit()
        {
        }
    I hope you got my point.
    Nokia Developer Wiki Moderation team

  5. #5
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Thank you for you all for help.

    i removed, but after one panic comes like "Program closed: HelloWorldbasic ALLOC:140ab9e40".


    Thank You

  6. #6
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    You are returning an CDesCArrayFlat "iGetSplitDataArr" from SplitStringL() function and in Appui this function get called and array returned by this function is deleted in Appui itself.Then you are also deleting the same in CSplit class.
    Instead of returning a array you should pass array as reference and delete the array in appui, this will solve your problem.No need to delete and assign memory to "iGetSplitDataArr" in CSplit class.

    cheers

  7. #7
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,336

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by SymbianTH View Post
    Thank you for you all for help.

    i removed, but after one panic comes like "Program closed: HelloWorldbasic ALLOC:140ab9e40".


    Thank You
    This is a memory leak. Now the problem is that, your iGetSplitDataArr is being allocated in the ConstructL of your CSplit class. It will be deleted only when you call option command ESPlitString. So you can allocate memory for iGetSplitDataArr only when you are sure to perform that SplitStringL function.

    Or call iSplit = CSplit::NewL(); in the ESPlitString case itself.


    Change your design flow and it will solve your problem.
    Nokia Developer Wiki Moderation team

  8. #8
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by SymbianTH View Post
    Thank you for you all for help.

    i removed, but after one panic comes like "Program closed: HelloWorldbasic ALLOC:140ab9e40".


    Thank You
    Problem is in following statement.

    //allocated memory
    CDesCArrayFlat *splitArr = new (ELeave) CDesCArrayFlat(1);
    //Leave alloacted memory and assigned iGetSplitDataArr to splitArr
    splitArr = iSplit->SplitStringL(KStr,KSplit);

  9. #9
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,336

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by savaj View Post
    Problem is in following statement.

    //allocated memory
    CDesCArrayFlat *splitArr = new (ELeave) CDesCArrayFlat(1);
    //Leave alloacted memory and assigned iGetSplitDataArr to splitArr
    splitArr = iSplit->SplitStringL(KStr,KSplit);
    Where is the problem? I see that he is deleting splitAtt just after that(See his first post). There is no any problem. Read my previous posts for more detailed answer.
    Nokia Developer Wiki Moderation team

  10. #10
    Regular Contributor
    Join Date
    Apr 2009
    Posts
    442

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Thank You very much

    i pass array(CDesCArrayFlat) as a parameter referance, and it's working.

    Thank you again

  11. #11
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73

    Smile Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by savaj View Post
    Problem is in following statement.

    //allocated memory
    CDesCArrayFlat *splitArr = new (ELeave) CDesCArrayFlat(1);
    //Leave alloacted memory and assigned iGetSplitDataArr to splitArr
    splitArr = iSplit->SplitStringL(KStr,KSplit);
    Problem has been defined and solved also.
    It was problem of returning onwership of array and deleting it 2 times.

  12. #12
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by kiran10182 View Post
    Where is the problem? I see that he is deleting splitAtt just after that(See his first post). There is no any problem. Read my previous posts for more detailed answer.
    Now m bit confused. i am talking about memory leak.

    //Here he allocating memory in pointer splitArr (asuume he get address location x after allocation)
    CDesCArrayFlat *splitArr = new (ELeave) CDesCArrayFlat(1);

    //here he is assigning memory location y (assume he is allocated memory loaction y in iGetSplitDataArr), and leaving memory location x untrackable.
    splitArr = iSplit->SplitStringL(KStr,KSplit);

    //deleting memory location y
    delete splitArr;
    splitArr = NULL;

    Then who delete location x???

    Now please explain, where is i am wrong??? i gotta confused.

  13. #13
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,336

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by savaj View Post
    Now please explain, where is i am wrong??? i gotta confused.
    Yeap. It should have been a simple pointer without any memory being allocated at that line, as it will receive ownership of iGetSplitDataArr. But it should be deleted later when it is used as shown in the code.

    Code:
    CDesCArrayFlat *splitArr;
    splitArr = iSplit->SplitStringL(KStr,KSplit);
    delete splitArr;
    splitArr = NULL;
    Moreover I don't see any good reason to declare it leave-aware with postfix L for SplitStringL.
    Nokia Developer Wiki Moderation team

  14. #14
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by kiran10182 View Post
    Yeap. It should have been a simple pointer without any memory being allocated at that line, as it will receive ownership of iGetSplitDataArr. But it should be deleted later when it is used as shown in the code.

    Code:
    CDesCArrayFlat *splitArr;
    splitArr = iSplit->SplitStringL(KStr,KSplit);
    delete splitArr;
    splitArr = NULL;
    Moreover I don't see any good reason to declare it leave-aware with postfix L for SplitStringL.
    Right, also function name SplitStringL() is some what misleading.

  15. #15
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: KERN-EXEC 3 panic comes when click on 'Exit' option.

    Quote Originally Posted by amitjoshi View Post
    Problem has been defined and solved also.
    It was problem of returning onwership of array and deleting it 2 times.
    Have you readed my post carefully before replying it???

    At that time SymbianTH is resolved panic KERN-EXE-3. Then he asked second question about memory leak, and mine answer was to that question (as i quoted that statement in my post).

Similar Threads

  1. KERN EXEC 3 in TransactionSubmitL
    By kdurga in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2008-08-06, 08:31
  2. Replies: 4
    Last Post: 2008-03-05, 09:30
  3. Using Bluetooth serial port in MIDlets (nokia 9500 issue)
    By orsteglasy in forum Mobile Java Networking & Messaging & Security
    Replies: 11
    Last Post: 2007-10-07, 21:49
  4. Replies: 2
    Last Post: 2007-07-19, 01:29
  5. My Nokia shows option 'EXIT' on all menus, Why?
    By Jordi Calella in forum Mobile Java General
    Replies: 1
    Last Post: 2005-07-01, 11:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •