×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2004
    Location
    Finland
    Posts
    22

    kern-exec 3 panic?

    I have a problem in my code and I don't know how to fix it. The problem appears only in target device.
    Here is the fuction what causes the kern-exec 3 panic in my target device. aBuffer is a message which comes from the socket. It contains variable number of submessages which starts with ** and end with *
    (example aBuffer = **submessage***submessage*.. and so on). Every submessage contains a struct and when the submessage is handled the information what is in it is sended to DecodeMessage().

    Code:
    void CWorkReporterEngine::HandleMessage(const TDesC8 &aBuffer)
    {
    TInt i = 0;
    TInt msgLength;
    TInt start;

    while(i < aBuffer.Length())
    {
    start = 2;

    while(start) //Search start of submessage '**'
    {
    if(i == aBuffer.Length()-1)
    return;
    if(aBuffer[i++] == 0x2a)
    if(aBuffer[i++] == 0x2a)
    start = 0;
    }

    MESSAGE_HEADER* resp = NULL;
    resp = (MESSAGE_HEADER*) &aBuffer[i]; //causes kern-exec 3 panic

    if(resp)
    msgLength = resp->uTotalLength;
    else
    return;

    TPtrC8 theMsg(aBuffer.Mid(i, msgLength));
    i += msgLength;

    if(aBuffer[i] == 0x2a) //Search end of submessage '*'
    {
    i++;
    DecodeMessage(theMsg, resp->uMessageID);
    }
    }

    iSocketsEngine->ContinueReading();
    iTimer->Cancel();
    iTimer->After(KTimeOut);
    }

    Problem is that, when the execution goes to second round of the while loop and the i happends to be uneven dereferencing of resp causes a panic and that is because the uTotalLength is on the previous round even. When i is even there is no problem. Problem happends because the resp isn't a 32-bit multiple and that's why the code is valid in the emulator.

    The declaration of MESSAGE_HEADER is
    Code:

    typedef struct
    {
    TUint16 uTotalLength;
    TUint16 uMessageID;
    } MESSAGE_HEADER;

    I have tried the Mem::Copy thing what is presented in "Developer Library/Tools and Utilities/Build tools guide/The native build targets". But still my code doesn't work in target.

    Only thing what I could do is that I modify my server-side code and make my messages uTotalLength be always uneven. But that isn't so great idea.

    But how I can fix this problem an make code work in target device?

  2. #2
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122
    Yes, it's definitely a memory alignment issue. x86 does not care about alignment (although accessing unaligned addresses is slower due to multiple reads/writes) while the ARM version raises an exception that manifests as KERN-EXEC 3.

    Mem::Copy() if done right will help. Please tell what you have tried. Another common way to make it work is to wrap the message object in a TPckgBuf.

    Lauri

Posting Permissions

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