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

  • Home
  • SEARCH
  • 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 8835161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:11:48+00:00 2026-06-14T09:11:48+00:00

I’m using Dr. Memory for memory debugging of a C program I wrote today.

  • 0

I’m using Dr. Memory for memory debugging of a C program I wrote today. This program, compiled with MinGW’s gcc only works when I run it from the debugger gdb, so I’m assuming its a memory error. The results.txt file Dr. Memory returned to me is something like:

Dr. Memory version 1.5.0 build 5 builton Aug 31 2012 16:19:51
Application cmdline: ""c:\Users\Lincoln\Desktop\USACO\gift1.exe""
Recorded 63 suppression(s) from default c:\Program Files\Dr. Memory/bin/suppress-default.txt

Error #1: UNINITIALIZED READ: reading register eflags
# 0 replace_memcmp               [d:\derek\drmemory\withwiki\trunk\drmemory\replace.c:557]
# 1 parseInputs                  [c:\Users\Lincoln\Desktop\USACO/gift1.c:55]
# 2 main                         [c:\Users\Lincoln\Desktop\USACO/gift1.c:126]
Note: @0:00:00.473 in thread 3824
Note: instruction: jnz    $0x7388a607

Error #2: UNINITIALIZED READ: reading register eax
# 0 parseInputs               [c:\Users\Lincoln\Desktop\USACO/gift1.c:55]
# 1 main                      [c:\Users\Lincoln\Desktop\USACO/gift1.c:126]
Note: @0:00:00.473 in thread 3824
Note: instruction: test   %eax %eax

Error #3: UNINITIALIZED READ: reading register esi
# 0 replace_memcmp               [d:\derek\drmemory\withwiki\trunk\drmemory\replace.c:556]
# 1 parseInputs                  [c:\Users\Lincoln\Desktop\USACO/gift1.c:55]
# 2 main                         [c:\Users\Lincoln\Desktop\USACO/gift1.c:126]
Note: @0:00:00.474 in thread 3824
Note: instruction: movzx  (%esi,%ecx,1) -> %edi

Error #4: UNADDRESSABLE ACCESS: reading 0x00000004-0x00000005 1 byte(s)
# 0 replace_memcmp               [d:\derek\drmemory\withwiki\trunk\drmemory\replace.c:556]
# 1 parseInputs                  [c:\Users\Lincoln\Desktop\USACO/gift1.c:55]
# 2 main                         [c:\Users\Lincoln\Desktop\USACO/gift1.c:126]
Note: @0:00:00.474 in thread 3824
Note: instruction: movzx  (%esi,%ecx,1) -> %edi

I have no idea how to read this, or where to start trying to fix my program. What do these error messages mean, and how do I fix them?

EDIT: This is my code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

struct personsData {
    char * name;
    int accountMoney, receivedMoney, numAquaintances;
};

void parseInputs( FILE * fin, int NP, struct personsData * person ) {

    int i;
    for ( i = 0; i < NP; i ++ )
        fscanf( fin, "%s", person[i].name );

    char * tempName_1;
    while ( !feof( fin ) ) {

        tempName_1 = malloc ( sizeof( char ) * 15 );
        fscanf( fin, "%s", tempName_1 );

        int index = 0;
        while ( memcmp( tempName_1, person[index].name, 15 ) != 0 )
            index ++;
        free( tempName_1 );

        fscanf( fin, "%d %d", &person[index].accountMoney, &person[index].numAquaintances );

        int b;
        char * tempName_2;
        for ( b = 0; b < person[index].numAquaintances; b ++) {
            tempName_2 = malloc( sizeof( char ) * 15 );
            fscanf( fin, "%s", tempName_2 );
            i = 0;
            while ( memcmp( tempName_2, person[i].name, 15 ) != 0 )
                i ++;

            free( tempName_2 );

            person[i].receivedMoney += ( int ) floor( person[index].accountMoney / person[index].numAquaintances );
            person[index].accountMoney = floor( person[index].accountMoney / person[index].numAquaintances ) * person[index].numAquaintances;

        }
    }

}

int main() {

    FILE * fin  = fopen ("gift1.in",  "r");
    FILE * fout = fopen ("gift1.out", "w");

    int NP;
    fscanf( fin, "%d", &NP);

    struct personsData person[NP];
    int i;
    for ( i = 0; i < NP; i ++ ) {
        person[i].accountMoney = 0;
        person[i].receivedMoney = 0;
        person[i].numAquaintances = 0;
        person[i].name = ( char * ) malloc ( sizeof( char ) * 15 );
    }

    parseInputs( fin, NP, person );

    for ( i = 0; i < NP; i ++ ) {
        // print to output file (and also to console for development purposes
        fprintf( fout,  "%s %d\n", person[i].name, person[i].receivedMoney - person[i].accountMoney );
        printf(         "%s %d\n", person[i].name, person[i].receivedMoney - person[i].accountMoney );
    }

    for ( i = 0; i < NP; i ++ ) {
        free( person[i].name );
    }

    exit(0);
}

And this is the input file gift1.in:

5
dave
laura
owen
vick
amr
dave
200 3
laura
owen
vick
owen
500 1
dave
amr
150 2
vick
owen
laura
0 2
amr
vick
vick
0 0
  • 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-06-14T09:11:49+00:00Added an answer on June 14, 2026 at 9:11 am

    Are you familiar at all with x86 assembly? If you aren’t, some of these errors will be kind of hard to explain. Either way, it’s telling you what lines of your code are involved in the tracebacks, like the first one:

    # 0 replace_memcmp               [d:\derek\drmemory\withwiki\trunk\drmemory\replace.c:557]
    # 1 parseInputs                  [c:\Users\Lincoln\Desktop\USACO/gift1.c:55]
    # 2 main                         [c:\Users\Lincoln\Desktop\USACO/gift1.c:126]
    

    In general, these errors appear to indicate that you’re passing uninitialized memory to memcmp() and dereferencing a NULL pointer. But, as Mitch suggests, we’ll need to see the code to say for sure.

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

Sidebar

Related Questions

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 parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.