×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    19

    kern exec 3 panic

    Hi ,
    I am getting a kern exec 3 panic in the following code . I am getting this panic in insert_student(....) FUNCTION.
    in the line "error = view.Prepare(iStudentDb, TDbQuery(sqlStr, EDbCompareFolded));" value of iStudentDb = Cant read memory from adress 0x000008 . how to resolve this panic ?? what should i do so that iStudentDb can hold a proper address ?


    #include <badesca.h>
    #include <s32file.h>
    #include <bautils.h>
    #include <eikenv.h>
    #include "DBEngine.h"



    const TInt KArrayGranularity = 20;
    const int KCustomSqlMaxLength = 5000;


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

    CStudentDb::~CStudentDb()
    {
    Close();
    iFsSession.Close();
    }

    void CStudentDb::ConstructL()
    {
    TInt err = iFsSession.Connect();
    if(err)
    User::Leave(err);
    }

    CStudentDb::CStudentDb()
    {
    iOpen = EFalse;
    }

    TInt CStudentDb::OpenDb(const TFileName& aExistingStudentFile)
    {
    Close();

    if(!BaflUtils::FileExists(iFsSession, aExistingStudentFile))
    {
    return KErrNotFound;
    }

    TRAPD(error,
    iFileStore = CPermanentFileStore::OpenL(iFsSession, aExistingStudentFile,
    EFileRead|EFileWrite);
    iFileStore->SetTypeL(iFileStore->Layout());
    iStudentDb.OpenL(iFileStore,iFileStore->Root())
    );
    if(error!=KErrNone)
    {
    return error;
    }

    iOpen = ETrue;
    return KErrNone;
    }


    TInt CStudentDb::CreateDb(const TFileName& aNewStudentFile)
    {
    Close();


    TRAPD(error,
    iFileStore = CPermanentFileStore::ReplaceL(iFsSession, aNewStudentFile,
    EFileRead|EFileWrite);
    iFileStore->SetTypeL(iFileStore->Layout());
    TStreamId id = iStudentDb.CreateL(iFileStore);
    iFileStore->SetRootL(id);
    iFileStore->CommitL();

    CreateStudentsTableL();
    CreateStudentsIndexL();
    );

    if(error!=KErrNone)
    {
    return error;
    }
    iOpen = ETrue;
    return KErrNone;
    }


    TInt CStudentDb::Close()
    {
    iStudentDb.Close();
    if(iFileStore)
    {
    delete iFileStore;
    iFileStore = NULL;
    }
    iOpen = EFalse;
    return KErrNone;
    }


    TBool CStudentDb::IsOpen() const
    {
    return iOpen;
    }


    void CStudentDb::CreateStudentsTableL()
    {

    TDbCol nameCol(KStudentsNameCol, EDbColText);
    nameCol.iAttributes = TDbCol::ENotNull;
    TDbCol idCol(KStudentsIdCol, EDbColText);
    TDbCol dateCol(KStudentsDateCol, EDbColInt32);
    TDbCol monthCol(KStudentsMonthCol,EDbColInt32);
    TDbCol yearCol(KStudentsYearCol, EDbColInt32);
    TDbCol genderCol(KStudentsGenderCol, EDbColText);
    TDbCol ageCol(KStudentsAgeCol, EDbColText);
    TDbCol fatherCol(KStudentsFatherCol, EDbColText);
    TDbCol courseCol(KStudentsCourseCol, EDbColText);
    TDbCol semCol(KStudentsSemCol, EDbColText);
    TDbCol branchCol(KStudentsBranchCol, EDbColText);
    TDbCol schoolCol(KStudentsSchoolCol, EDbColText);
    TDbCol addressCol(KStudentsAddressCol, EDbColText);
    TDbCol universityCol(KStudentsUniversityCol, EDbColText);
    TDbCol mobileCol(KStudentsMobileCol, EDbColText);

    CDbColSet* studentColSet = CDbColSet::NewLC();
    studentColSet->AddL(nameCol);
    studentColSet->AddL(idCol);
    studentColSet->AddL(dateCol);
    studentColSet->AddL(monthCol);
    studentColSet->AddL(yearCol);
    studentColSet->AddL(dateCol);
    studentColSet->AddL(genderCol);
    studentColSet->AddL(ageCol);
    studentColSet->AddL(fatherCol);
    studentColSet->AddL(courseCol);
    studentColSet->AddL(branchCol);
    studentColSet->AddL(schoolCol);
    studentColSet->AddL(addressCol);
    studentColSet->AddL(universityCol);
    studentColSet->AddL(mobileCol);

    User::LeaveIfError(iStudentDb.CreateTable(KStudentsTable,
    *studentColSet));
    CleanupStack::PopAndDestroy(studentColSet);
    }


    void CStudentDb::CreateStudentsIndexL()
    {
    TDbKeyCol nameCol(KStudentsNameCol);
    TDbKeyCol schoolCol(KStudentsSchoolCol);

    CDbKey* index = CDbKey::NewLC();
    index->AddL(nameCol);
    index->AddL(schoolCol);
    User::LeaveIfError(iStudentDb.CreateIndex(
    KStudentsIndexName, KStudentsTable, *index));
    CleanupStack::PopAndDestroy(index);
    }

    TBool CStudentDb::insert_student(const TDesC& name,const TDesC& id,const TInt date,const TInt month,const TInt year,
    const TDesC& gender,const TDesC& age,const TDesC& father,const TDesC& course,const TDesC& sem,const TDesC& branch,const TDesC& school,const TDesC& address,const TDesC& university,const TDesC& mobile )
    {
    _LIT(KSelect, "SELECT ");
    _LIT(KFrom, " FROM ");
    _LIT(KOrderBy, " ORDER BY ");
    _LIT(KDot, ", ");


    TBuf<KCustomSqlMaxLength> sqlStr;

    sqlStr.Append(KSelect);
    sqlStr.Append(name);
    sqlStr.Append(KDot);
    sqlStr.Append(id);
    sqlStr.Append(KDot);
    sqlStr.Append(date);
    sqlStr.Append(KDot);
    sqlStr.Append(month);
    sqlStr.Append(KDot);
    sqlStr.Append(year);
    sqlStr.Append(KDot);
    sqlStr.Append(gender);
    sqlStr.Append(KDot);
    sqlStr.Append(age);
    sqlStr.Append(KDot);
    sqlStr.Append(father);
    sqlStr.Append(KDot);
    sqlStr.Append(course);
    sqlStr.Append(KDot);
    sqlStr.Append(sem);
    sqlStr.Append(KDot);
    sqlStr.Append(branch);
    sqlStr.Append(KDot);
    sqlStr.Append(school);
    sqlStr.Append(KDot);
    sqlStr.Append(address);
    sqlStr.Append(KDot);
    sqlStr.Append(university);
    sqlStr.Append(KDot);
    sqlStr.Append(mobile);
    sqlStr.Append(KFrom);
    sqlStr.Append(KStudentsTable);
    sqlStr.Append(KOrderBy);
    sqlStr.Append(name);
    sqlStr.Append(KDot);
    sqlStr.Append(KStudentsSchoolCol);


    RDbView view;
    TInt error;
    error = view.Prepare(iStudentDb, TDbQuery(sqlStr, EDbCompareFolded)); // PANIC Kern Exec 3
    if(error!=KErrNone)
    {
    return error;
    }
    error = view.EvaluateAll();
    if(error!=KErrNone)
    {
    return error;
    }
    RDbColWriteStream writeStream;

    TRAP(error,
    view.InsertL();
    view.SetColL(1,name);
    view.SetColL(2,id );
    view.SetColL(3,date);
    view.SetColL(4,month);
    view.SetColL(5,year);
    writeStream.OpenL(view,6);
    writeStream.WriteL(gender);

    writeStream.OpenL(view, 7);
    writeStream.WriteL(age);

    writeStream.OpenL(view, 8);
    writeStream.WriteL(father);

    writeStream.OpenL(view, 9);
    writeStream.WriteL(father);

    writeStream.OpenL(view, 10);
    writeStream.WriteL(course);

    writeStream.OpenL(view, 11);
    writeStream.WriteL(sem);

    writeStream.OpenL(view, 12);
    writeStream.WriteL(course);

    writeStream.OpenL(view, 13);
    writeStream.WriteL(school);

    writeStream.OpenL(view, 14);
    writeStream.WriteL(course);

    );
    if(error!=KErrNone)
    {
    return error;
    }
    writeStream.Close();
    TRAP(error, view.PutL());
    if(error!=KErrNone)
    {
    return error;
    }
    view.Close();
    return KErrNone;

    return ETrue;

    }

    Thanking you
    Ganesh

  2. #2
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Bangalore
    Posts
    208

    Re: kern exec 3 panic

    Hi Ganesh,

    Regarding yur member data iStudentDb -> it must be deleting either in the destructor
    or somewhere in yur code. Debug it u will cme to know.

    and regarding the insert_student, u r calling from the UI, but there u are not creating the instance of yur engine.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    19

    Re: kern exec 3 panic

    Hi mdzahidul_haque ,
    I debugged the code . But i am not able to make out where the iStudentDb value is getting deleted.
    And i have created the instance of the DBEngine . Can you please give me some suggestions ? Can i mail you the code ? can you debug n let me know where d problem is ? N thank you for helping me a lot . please guide me through this

    Regards,
    Ganesh

  4. #4
    Registered User
    Join Date
    Jul 2007
    Location
    Noida
    Posts
    1,503

    Re: kern exec 3 panic

    Try to increase EPOCSTACKSIZE in your MMP file, i am not sure but i solved many times KErnExec 3 by increasing EPOCStackSize.
    Regards,
    Amit


    ****"Putting a Smile on other's faces is the essence of true Happiness"****

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    19

    kern exec 3 panic

    Hi,
    I have increased the stack size , still i am getting the panic

  6. #6
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Bangalore
    Posts
    208

    Re: kern exec 3 panic

    in the appui,the method which u have used for creating the instance of yur engine,
    that shld be called in the appui::constructl()

    u try doing this it will solve yur prob

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    19

    Re: kern exec 3 panic

    Hi,
    I have implemented whatever u suggested . But it is still not working

  8. #8
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Bangalore
    Posts
    208

    Re: kern exec 3 panic

    then u need to manually clean the project, delet the build folder and again build yur proj from the cmd . it will sure solve yur prob

Similar Threads

  1. Panic - Kern Exec 3
    By ganeshs87 in forum Symbian
    Replies: 9
    Last Post: 2010-03-09, 10:35
  2. getting panic KERN - EXEC 3
    By rohitnegi in forum Symbian User Interface
    Replies: 2
    Last Post: 2010-02-22, 11:01
  3. panic kern exec 3 error need help
    By urban37 in forum Symbian User Interface
    Replies: 13
    Last Post: 2008-12-17, 08:24
  4. Replies: 4
    Last Post: 2008-03-05, 09:30
  5. Replies: 2
    Last Post: 2007-07-19, 01:29

Posting Permissions

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