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 8756119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:59:44+00:00 2026-06-13T13:59:44+00:00

Here is the code snippet which I want to debug: When I try to

  • 0

Here is the code snippet which I want to debug:
When I try to debug using GDB, after the loop gets over for i = 0, it does not jump to the very first line inside the loop for i = 1. Instead it jumps to another line in the middle and then jumps to the first line. I am not able to figure out why and how to fix it. Please give me your inputs.

for(i = 0; i < fileSum; i++)
{
    char *fileName ; //= NULL;
//  fileName = GetFileName(dataset->groundTruthFolder, trainImageFiles[i], dataset->groundTruthExtension);

    fileName = new char[strlen(dataset->groundTruthFolder) + strlen(trainImageFiles[i]) + strlen(dataset->groundTruthExtension) + 1];
    sprintf(fileName, "%s%s%s", dataset->groundTruthFolder, trainImageFiles[i], dataset->groundTruthExtension);
    printf("GetFileName: fileName-%s \n", fileName);


    LLabelImage groundTruth(fileName, domain);
//      delete[] fileName;
//      fileName = NULL;

    int width = groundTruth.GetWidth(), height = groundTruth.GetHeight();

    int subWidth = (width + subSample - 1) / subSample;
    int subHeight = (height + subSample - 1) / subSample;

    for(k = 0; k < subHeight; k++) for(j = 0; j < subWidth; j++)
    {
        unsigned char gtVal = groundTruth(j * subSample, k * subSample, 0);
        if(gtVal > 0) classCounts[gtVal - 1]++, total++;
        printf("k = %d,j = %d, gtVal = %d\n", k, j, gtVal);
    }
    int dummy = 0; 
    printf("i = %d\n", i);
}

Here is the gdb console’s snapshot:

Breakpoint 2, LDenseUnaryPixelPotential::InitTrainData (this=0x80aad08, trainImageFiles=...) at potential.cpp:665
665         int dummy = 0; 
(gdb) n
666         printf("i = %d\n", i); 
(gdb) n
i = 1
650         LLabelImage groundTruth(fileName, domain);
(gdb) n
640     for(i = 0; i < fileSum; i++)
(gdb) n

Breakpoint 1, LDenseUnaryPixelPotential::InitTrainData (this=0x80aad08, trainImageFiles=...) at potential.cpp:645
645         fileName = new char[strlen(dataset->groundTruthFolder) + strlen(trainImageFiles[i]) + strlen(dataset->groundTruthExtension) + 1];
(gdb) 

Please notice that, the control goes from 666 to 650 and then to 640, instead of going directly from 666 to 640.

Previously, I was compiling with -g option , now I compiled with -g -O0 option. Still the same problem persists.

Here is my Makefile:

CC  =   g++
OBJS    =   main.o
SOURCES =   main.cpp
LIBS    =       -lIL -pthread
EXE =   ale
FLAGS   = -g -O0 -Wno-write-strings

$(EXE): .
    $(CC) $(FLAGS) -c $(SOURCES) -o $(OBJS)
    $(CC) -o $(EXE) $(OBJS) $(LIBS)
clean: 
    rm -rf *.o ale
  • 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-13T13:59:45+00:00Added an answer on June 13, 2026 at 1:59 pm

    Actually, I debugged further and found that when the control reaches the end of the loop, the destructor of “LLabelImage” is being invoked to delete the data.

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

Sidebar

Related Questions

Here is the following code-snippet I'm using in my Google Spreadsheet onEdit() function: else
I'm reading a csv file using c# here is a little code snippet. using
Here is a code snippet, that shows what I want and the error, that
In this thread I found a JavaScript code snippet which I want to use.
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is my code snippet where I'am taking confidence with initialization blocks class Father{
I have a class with two constructors (C#). Here is the code snippet: public
I don't know why I'm facing that error ! Here is my code snippet
here is the relevent code snippet: public static Rand searchCount (int[] x) { int
Here's the relevant code snippet. public static Territory[] assignTerri (Territory[] board, String[] colors) {

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.