I'm working on a project and I came to a point where the following stack trace popped up:
#0 0x0017c30c in _IO_flush_all_lockp () from /lib/libc.so.6
#1 0x0017d030 in _IO_cleanup () from /lib/libc.so.6
#2 0x0013e042 in exit () from /lib/libc.so.6
#3 0x00126bbe in __libc_start_main () from /lib/libc.so.6
#4 0x08049d11 in _start ()
(Code removed because that memory leak was solved. There are others, of course. I'll try harder to track them down before posting them here though. :) The initial problem may not be related to memory leaks. )
First of all, am I even looking in the right direction from the initial stack trace? I've never seen this one before when dealing with memory issues. Any ideas?
Edit: Someone said it was due to visual_mem_new0. That function simply allocates memory. It knows nothing about plugin->author.
Edit: Duh. The memcopy right before the strdup fills the memory in.
Edit: Ok, that gets rid of the one memory leak. I'm not convinced the initial stack trace is all about a memory leak -- it's still there for example. It's trying to release some resource I believe. Part of this program uses a lot of compiled assembly (JIT compiler), which uses mmap'd memory on top of a file descriptor for a buffer. I'm closing the file. Is there something I need to do with the memory map?
I'll keep trying to clear these memory leaks out of the way, though. I did something recently that's related to a particular plugin. The program only hangs on close when I run that plugin, which uses the memory map I spoke of. I'm not sure what it could be. I made some minor changes. Initially I suspected a shared pointer that I keep track of references for. It uses the same system used all throughout libvisual, and no memory leaks specific of that is showing up. At any rate, I hope someone has some clues about it. I can't think of anything else to add.
Edit: Ok, tracked it down with the help of revision history. What's wrong with the following code? Can I not copy output onto itself like that?
static inline int dump_stack(AvsCompilerContext *ctx)
{
AvsCompilerArgument *pa;
char output[2048];
snprintf(output, 2047, "\ncompiler: stackdump: Stack dump\n");
for (pa=(AvsCompilerArgument *)ctx->stack->base; pa < (AvsCompilerArgument *)ctx->stack->pointer; pa++) {
snprintf(stderr, 2047, "%scompiler: stackdump: [%2d] = ", output, (pa - (AvsCompilerArgument *)ctx->stack->base));
switch (pa->type) {
case AvsCompilerArgumentInvalid:
snprintf(output, 2047, "%sinvalid", output);
break;
case AvsCompilerArgumentConstant:
snprintf(output, 2047, "%s%.2f", output, pa->value.constant);
break;
case AvsCompilerArgumentIdentifier:
snprintf(output, 2047, "%s", pa->value.identifier);
break;
case AvsCompilerArgumentMarker: {
char *markers[] = { "invalid", "function", "argument", NULL };
snprintf(output, 2047, "%s--- %s marker ---", output, markers[pa->value.marker]);
break;
}
case AvsCompilerArgumentPrivate:
snprintf(output, 2047, "%sprivate", output);
break;
}
snprintf(output, 2047, "\n");
}
avs_debug(print(output));
return VISUAL_OK;
}
The macro avs_debug does nothing. I commented its content out.