[uClinux-dev] Re: Apparent memory corruption using ColdFire 5272 (Stuart MacDonald)

Ed Orchard edorchard at yahoo.com
Tue Mar 25 09:55:01 EST 2003


From: "Ed Orchard" <edorchard at yahoo.com>
>> I've got some code that runs several tasks by means of vfork(). If I add
>> some trivial code it now crashes or behaves strangely. Elsewhere in
another
>> task with a few lines of code added that task stops responding - even
though
>> those lines of code are not used. It looks like a memory corruption
problem
>> so I have doubled the stack size to no avail. Can anyone tell me how to
find
>> out what's going on? I have plenty of embedded experience but am fairly
new
>> to Linux so am not familiar with the tools available to me - so don't be
>> afraid to state the obvious :-). Many thanks.

>First thing you can do is provide a better description of the >problem:
>what hardware? what's the exact code having problems? what have >you
>already tried/looked for/read/searched on the net? It's rarely >bad to
>have too much detail when asking for help.

Thanks for the response, Stuart.
Hardware: Arcturus 5272 Colfire uCdimm (I believe).
The code that spawns a task is:-
{
    char    strParam1[10];
    char    strParam2[10];

    if(0 == (pid = vfork()))
    {
        sprintf(strParam1, "%X", param1);
        sprintf(strParam2, "%X", param2);
        (void)execl
            (
                "/bin/newtask",
                "newtask",
                strParam1,
                strParam2,
                NULL
            );
        _exit(0);
    }
}

The child has the form:-
static void   newtask(int param1, int param2);

int main(
    int     argc,   /* number of parameters */
    char    **argv) /* command line parameters */
{
    int param1;
    int param2;

    /* This is done in hex as there is/was a fault in sprintf omitting the
last digit of a negative number */
    sscanf(argv[1], "%X", &param1);
    sscanf(argv[2], "%X", &param2);

    newtask(param1, param2);
    _exit(0);
}

static void newtask(int param1, int param2)
{
    /* main body of child task */
}

One of the parameters contains an open file descriptor from which I read.
There is also some error handling which is not shown.
I also have my own implementation of shared memory which exploits the lack
of a MMU and has checks to ensure that it writes to the right place.

The remainder of the code (which is probably too lengthy to put here) parses
text from either the file descriptor or another fifo and acts on the
commands via a switch statement. It makes calls to the bootloader to read
and write parameters from/to the environment.
Without certain switch statements all is well. Include the extra statements
and the following function is entered but never exits:

static void controlAccessNode(int command, int msgSequence, char *token)
 {
    switch(command)
    {
        case AN_SET_SERVER_ADDRESS:
            strncpy(shared->config.serverAddress, token, sizeof
shared->config.serverAddress);
            updateConfigStr("SERVER_ADDRESS", shared->config.serverAddress);
            break;

/* other caes statements here */

        default:
            ERROR("Unknown command %d", command);
            break;
    }
}


Is this enough to indicate where to look for a problem?








More information about the uClinux-dev mailing list