Panda142308
Panda142308

Reputation: 27

General Protection Fault when using Valgrind

Apologies in advance for not adding code as I do not have permission to do so.

I have a program that is crashing on certain systems after variable amounts of time ranging from 2-10s after starting with Valgrind massif tool. Running the same with gdb or running the application as is does not cause any crashes.

This works fine - valgrind --tool=massif --pages-as-heap=yes ./<prog> <prog_args>

This causes program to abort with SIGSEGV valgrind --tool=massif --stacks=yes ./<prog> <prog_args>

The function at the top of the traceback when program terminates with Valgrind is like so, line number pointing to the if condition statement with flags:

<enum_type>
tmr_fn(ctx *ctx, tmr_t *tmr, const char *fn, unsigned int ln)
{
    int ret = ENUM_0
    if (ctx == NULL || tmr == NULL)
        return (ENUM_ERR);

    if (tmr->flags & 0x1) {
        tmr->flags |= 0x2;
        return (0);
    }
...
}

I tried looking for answers but have not found anything useful yet. Any help or pointers would be really great!

Upvotes: 0

Views: 1512

Answers (1)

Panda142308
Panda142308

Reputation: 27

Running the program with memcheck indicated unintialized values. I figured out the tmr structure had been declared, but memset was not done and had some garbage values. This caused issues in the tmr_fn which was called in a free-ing routine.

Upvotes: 0

Related Questions