LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   debug output: deciphering help needed. (https://www.linuxquestions.org/questions/programming-9/debug-output-deciphering-help-needed-4175627998/)

BW-userx 04-19-2018 11:39 AM

debug output: deciphering help needed.
 
so what is this trying to tell me?
codeblocks :: debugger output.

this is a read directory recursively getting whatever file that is within a directory and its sub-directories. then before adding the files into a link list, it checks for an extension if it matches the criteria then it is called to add it to the front of a link list. it loads up a bunch then fails giving me this error.

I am wanting to get it to run through an entire hdd if called to do so, then only get the file types it is suppose to then load them into the link list without blowing up.

Code:

#0 0x7ffff707f428        __GI_raise(sig=sig@entry=6) (../sysdeps/unix/sysv/linux/raise.c:54)
#1 0x7ffff708102a        __GI_abort() (abort.c:89)
#2 0x7ffff70c72e8        __malloc_assert (assertion=assertion@entry=0x7ffff71db190 "(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) &&((unsigned long) (malloc.c:301)
#3 0x7ffff70cb426        sysmalloc(nb=nb@entry=48, av=av@entry=0x7ffff740eb20 <main_arena>) (malloc.c:2391)
#4 0x7ffff70cc743        _int_malloc(av=av@entry=0x7ffff740eb20 <main_arena>, bytes=bytes@entry=32) (malloc.c:3827)
#5 0x7ffff70ce184        __GI___libc_malloc(bytes=32) (malloc.c:2913)
#6 0x401ea6        add_2_front(filelist=0x6066d0 <filelist>, filename=0x760fd0 "/home/userx/Dropbox/images/eva green/thCAAB42OY.jpg") (/media/userx/b454fa4b-5a36-4124-af4f-9ad2e90eaf28/userx/C++Projects/wmslideshow/filelist.c:140)
#7 0x402614        add_file_to_filelist_recursively(origpath=0x760af0 "/home/userx/Dropbox/images/eva green/thCAAB42OY.jpg", level=1 '\001') (/media/userx/b454fa4b-5a36-4124-af4f-9ad2e90eaf28/userx/C++Projects/wmslideshow/filelist.c:352)
#8 0x40255b        add_file_to_filelist_recursively(origpath=0x760ee0 "/home/userx/Dropbox/images/eva green", level=1 '\001') (/media/userx/b454fa4b-5a36-4124-af4f-9ad2e90eaf28/userx/C++Projects/wmslideshow/filelist.c:335)
#9 0x40255b        add_file_to_filelist_recursively(origpath=0x61ace0 "/home/userx/Dropbox/images", level=1 '\001') (/media/userx/b454fa4b-5a36-4124-af4f-9ad2e90eaf28/userx/C++Projects/wmslideshow/filelist.c:335)
#10 0x40255b        add_file_to_filelist_recursively(origpath=0x7fffffffea5b "/home/userx/Dropbox", level=0 '\000') (/media/userx/b454fa4b-5a36-4124-af4f-9ad2e90eaf28/userx/C++Projects/wmslideshow/filelist.c:335)
#11 0x4036d6        main(argc=3, argv=0x7fffffffe738) (/media/userx/b454fa4b-5a36-4124-af4f-9ad2e90eaf28/userx/C++Projects/wmslideshow/main.c:164)


The thing is, that I can run this program on my other hdd the entire thing that has all kinds of files on it and it does not blow up. only in Dropbox and my /home/user dir,

when it is my home dir it grabs this file then fails.

Code:

bad path /home/userx/.mozilla/firefox/x22f7d38.default/lock
But that is a different issue all together.

In C++ for a different program I wrote this does not occur. But that is C++. ;)

I'm not sure how much or which code one needs to look at to see from that debugger output. SO, if need be let me know what you think you'll be needing to look at in conjunction with this.

thanks.

bodqhrohro 04-19-2018 12:53 PM

There is a lot of assertions in backtrace so it's hard to distinguish which one causes the failure without reading the code. I have an interesting observation that both of file paths are slightly longer than 50 symbols. Maybe you have a memory corruption issue? Are buffer sizes enough for fitting any paths? Does the program process successfully any longer file paths before the failure?

BW-userx 04-19-2018 01:14 PM

Quote:

Originally Posted by bodqhrohro (Post 5845254)
There is a lot of assertions in backtrace so it's hard to distinguish which one causes the failure without reading the code. I have an interesting observation that both of file paths are slightly longer than 50 symbols. Maybe you have a memory corruption issue? Are buffer sizes enough for fitting any paths? Does the program process successfully any longer file paths before the failure?



Code:

// in header I kicked it up to 2048

#ifndef PATH_MAX
#define PATH_MAX 2048 //1024
#endif // PATH_MAX

    char cwd[PATH_MAX];
    char fullpath[PATH_MAX];
    char temp[PATH_MAX];

let me go experiment with path lengths to see what I see. maybe kick it up further to see what that does as well.

Code:

char *get_absolute_path(char *path)
{

    char cwd[PATH_MAX];
    char fullpath[PATH_MAX];
    char temp[PATH_MAX];
    char *ret;

    if (!path)
        return(NULL);
    if (path[0] == '/' )
        return(strdup(path));
    /* This path is not relative. We're gonna convert it, so that a
      filelist file can be saved anywhere and feh will still find the
      images */

    /* I SHOULD be able to just use a simple realpath() here, but dumb *
      old Solaris's realpath doesn't return an absolute path if the
      path you give it is relative. Linux and BSD get this right... */
    if (getcwd(cwd, sizeof(cwd)) == NULL)
        printf("Cannot determine working directory:");
    snprintf(temp, sizeof(temp), "%s/%s", cwd, path);
    if (realpath(temp, fullpath) != NULL) {
        ret = strdup(fullpath);
    } else {
        ret = strdup(temp);
    }

    return(ret);
}

EDIT:

Ok I just made it 4096, and that worked (so far) one test only. I was thinking it may have been something to do with the linked list. but yeah, thanks!!!

marking solved.


All times are GMT -5. The time now is 03:08 PM.