Sponsored Content
Full Discussion: id3lib SEGFAULT
Top Forums Programming id3lib SEGFAULT Post 302389324 by errb on Sunday 24th of January 2010 08:14:00 AM
Old 01-24-2010
Java id3lib SEGFAULT

Hello everyone,
I'm writing a program using the id3lib unfortunately I've encountered with memory issue that cause segmentation fault. I tried to rerun and analyze the program with valgrind but it doesn't point me anywhere. I really stuck on this one.

Valgrind output:
Code:
==14716== Invalid read of size 4

==14716==    at 0x404BEFC: ID3_Frame::GetField(ID3_FieldID) const (in /usr/lib/libid3-3.8.so.3.0.0)

==14716==    by 0x8049BD0: Parse_mask(char const*, char const*, ID3_TagType) (in /home/earlcash/dev/id3fcp/id3fcp)

==14716==    by 0x804967D: main (in /home/earlcash/dev/id3fcp/id3fcp)

==14716==  Address 0x4 is not stack'd, malloc'd or (recently) free'd

==14716==

==14716== Process terminating with default action of signal 11 (SIGSEGV)

==14716==  Access not within mapped region at address 0x4

==14716==    at 0x404BEFC: ID3_Frame::GetField(ID3_FieldID) const (in /usr/lib/libid3-3.8.so.3.0.0)

==14716==    by 0x8049BD0: Parse_mask(char const*, char const*, ID3_TagType) (in /home/earlcash/dev/id3fcp/id3fcp)

==14716==    by 0x804967D: main (in /home/earlcash/dev/id3fcp/id3fcp)

==14716==

==14716== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 21 from 1)

==14716== malloc/free: in use at exit: 775 bytes in 6 blocks.

==14716== malloc/free: 16 allocs, 10 frees, 9,487 bytes allocated.

==14716== For counts of detected errors, rerun with: -v

==14716== searching for pointers to 6 not-freed blocks.

==14716== checked 130,888 bytes.

'Parse_mask' definition:
Code:
const char *Parse_mask(const char *filename, const char *mask, ID3_TagType id3_ver){
    p_symbols event[] =
    {
        { "%n", ID3FID_TRACKNUM },
        { "%i", ID3FID_ORIGARTIST },
        { "%t", ID3FID_TITLE },
        { "%a", ID3FID_ALBUM },
    //    { "%g", ID3FID_ },
        { "%y", ID3FID_ORIGYEAR },
    //    { "%c",  },
        { NULL, ID3FID_NOFRAME }
    };
    string s_mask = mask;
    ID3_Tag file;
    /*ID3_Frame *f_frame = NULL;
    ID3_Field *f_field = NULL;*/
    char tag_buff[255];
    int iter = 0;
    size_t match;

    if(file.Link(filename, id3_ver) == 0){
        return NULL;    
    }
    
    while(event[iter].symbol != NULL){
        
        if((match = s_mask.find(event[iter].symbol)) != string::npos){
            file.Find(event[iter].frame_id)->GetField(ID3FN_TEXT)->Get(tag_buff, 255);
            s_mask.replace(match, strlen(event[iter].symbol), tag_buff);
            iter++;
            continue;
        }
        iter++;
    }

    file.Clear();
    s_mask += ".mp3";
    return s_mask.c_str();
}

Thanks in advance Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

gnu history library signal segfault

i am trying to use the history functions in a c++ program along with a custom signal handler for SIGINT. the prog works fine catching signals without the line: add_history(*args); but as soon as this line is added, the prog segfaults on SIGINT. does anyone have experience using gnu... (2 Replies)
Discussion started by: a1g0rithm
2 Replies

2. UNIX for Dummies Questions & Answers

[Linux] How Do I Run Until Segfault

Hello, sorry if this has been posted before but i was wondering if there is a way to run a program until a segmentation fault is found. Currently i'm using a simple shell script which runs my program 100 times, sleeps 1 second because srand(time(0)) is dependent on seconds. Is there a possible... (1 Reply)
Discussion started by: aslambilal
1 Replies

3. Programming

how to avoid the segfault from Address 0x1cd00000103 out of bounds

After allocating memory for some variables, segfault is often to happen, due to the same reason: Address 0x1cd00000103 out of bounds It is welcome to recommend some treatments. Thanks e.g. is_done = 0x1cd00000103 <Address 0x1cd00000103 out of bounds>, hood = 0x23c00000247, c =... (11 Replies)
Discussion started by: cdbug
11 Replies

4. Solaris

Working around netscape 4.9 segfault on Solaris 8

We have a Solaris 8 server which users login to via VNC to get a desktop. On that desktop these users use Netscape Communicator 4.9 to access a very important mail account. Unfortunately Netscape has started segfaulting regularly. Does anyone have any ideas how I can try to find out what point... (1 Reply)
Discussion started by: aussieos
1 Replies

5. Programming

2 Problems: Segfault on ctrl+c and syslog() prob

1. Even if i have the handles for ctrl+c it gives off a segfault 2. syslog doesn't log LOG_ERR event with log masked specified or non specified, it logs LOG_WARNING however... #include <sys/types.h> /* include this before any other sys headers */ #include <sys/stat.h> #include <fcntl.h>... (2 Replies)
Discussion started by: james2432
2 Replies

6. UNIX for Dummies Questions & Answers

Compiling with debugger flag -g fixes SEGfault (fortran90)

So the title kinda says it all. I was getting a SEGfault, so I decided to compile with the -g option to find where, and low and behold the SEGfault doesn't occur. I suppose the answer is "Problem solved! You fixed yet another SEGfault." But I am very curious how this could have happened. ... (3 Replies)
Discussion started by: drbones
3 Replies

7. Programming

Is Drive Valid Segfault

I have a program that allows users to specify the debug log file location and name. I have tried using the access() and stat() but they both segfault if the drive say (d:\) is invalid. Both seem to be fine if the drive exists. Could someone please point me in the direction to a function that... (1 Reply)
Discussion started by: robfwauk
1 Replies

8. Programming

segfault in pointer to string program

hello all, my question is not about How code can be rewritten, i just wanna know even though i am not using read only memory of C (i have declared str) why this function gives me segfault :wall:and the other code executes comfortably though both code uses same pointer arithmetic. ... (4 Replies)
Discussion started by: zius_oram
4 Replies

9. Programming

String array iteration causing segfault

I am populating an array of string and print it. But it going in infinite loop and causing segfault. char Name = { "yahoo", "rediff", "facebook", NULL }; main(int argc, char* argv) { int j = 0; ... (7 Replies)
Discussion started by: rupeshkp728
7 Replies

10. Programming

Segfault When Parsing Delimiters In C

Another project, another bump in the road and another chance to learn. I've been trying to open gzipped files and parse data from them and hit a snag. I have data in gzips with a place followed by an ip or ip range sort of like this: Some place:x.x.x.x-x.x.x.x I was able to modify some code... (6 Replies)
Discussion started by: Azrael
6 Replies
SM2FILE(1)							  ICI executables							SM2FILE(1)

NAME
sm2file - shared-memory linked list data extraction test program SYNOPSIS
sm2file DESCRIPTION
sm2file stress-tests shared-memory linked list data extraction by retrieving and deleting all text file lines inserted into a shared-memory linked list that is the root object of a PSM partition named "file2sm". The operation of sm2file echoes the cyclical operation of file2sm: the EOF lines inserted into the linked list by file2sm punctuate the writing of files that are copies of file2sm's original source text file. The name of each file written by sm2file is file_copy_cycleNbr, where cycleNbr is, in effect, the count of EOF lines encountered in the linked list up to the point at which the writing of this file began. sm2file may catch up with the data ingestion activity of file2sm, in which case it blocks (taking the file2sm test semaphore) until the linked list is no longer empty. EXIT STATUS
0 sm2file has terminated. FILES
No configuration files are needed. ENVIRONMENT
No environment variables apply. DIAGNOSTICS
can't attach to shared memory Operating system error. Check errtext, correct problem, and rerun. Can't manage shared memory. PSM error. Check for earlier diagnostics describing the cause of the error; correct problem and rerun. Can't create shared memory list. PSM error. Check for earlier diagnostics describing the cause of the error; correct problem and rerun. Can't create semaphore. ION system error. Check for earlier diagnostics describing the cause of the error; correct problem and rerun. Can't open output file Operating system error. Check errtext, correct problem, and rerun. can't write to output file Operating system error. Check errtext, correct problem, and rerun. BUGS
Report bugs to <ion-bugs@korgano.eecs.ohiou.edu> SEE ALSO
file2sm(1), smlist(3), psm(3) perl v5.14.2 2012-05-25 SM2FILE(1)
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy