Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 572881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:39:55+00:00 2026-05-13T13:39:55+00:00

I’m working on a project and I came to a point where the following

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:39:55+00:00Added an answer on May 13, 2026 at 1:39 pm

    Since you’re doing strdup(), you should free the values using free(). I am not sure if visual_mem_free() calls free(). If you try free() instead of visual_mem_free(), does the valgrind error go away?

    Edit: Your snprintf() calls are wrong:

    snprintf(output, 2047, "%sinvalid", output);
    

    snprintf() is C99, and the standard says (7.19.6.5p2):

    If copying takes place between objects that overlap, the behavior is undefined.

    The exact statement is for sprintf() in C89 as well.

    The easiest way to fix your problem would be something like:

    char init[] = "\ncompiler: stackdump: Stack dump\n";
    size_t init_len = sizeof init - 1;
    snprintf(output, 2047, "\ncompiler: stackdump: Stack dump\n");
    

    followed by:

    snprintf(output+init_len, sizeof output - init_len, "%.2f", pa->value.constant);
    

    (Do check for off-by-one errors above.)

    Also, I am not sure why you’re calling snprintf() with stderr as its first argument in one of the calls. Are you compiling your code with warnings enabled?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.