ben-strasser / fast-cpp-csv-parser

fast-cpp-csv-parser
BSD 3-Clause "New" or "Revised" License
2.13k stars 441 forks source link

free(): invalid pointer #116

Closed lk-dll closed 3 years ago

lk-dll commented 3 years ago

Hi,

trying to go through 2 files a read the content, read in a separate run is ok, but when I run the code like in my example I got an error:

free(): invalid pointer

My program is like:

int main( void ){
    // definitions, etc.

    processFile( path_1, ...arrays, variables );
    processFile( path_2, ...arrays, variables );
}

void processFile( char *path, ...arrays, variables ){
    // definitions
    io::CSVReader< 44 > in( path );
    in.read_header( io::ignore_extra_column, ...column_names... );

    while( in.read_row( ...columns... ) ){
        // do some stuff with lines
    }

    return;
}

Pls help.

ben-strasser commented 3 years ago

Hi,

thanks for the bug report. Can you provide a minimum compiling example with CSV file?

Best Regards Dr. Ben Strasser

lk-dll commented 3 years ago

Hi Ben, I'm not able to reproduce an error in some minimum compilable example, so I had to provide you a bigger part of the code.

I'm using these 2 datasets: [ 1 ] https://www.unsw.adfa.edu.au/unsw-canberra-cyber/cybersecurity/ADFA-NB15-Datasets/a%20part%20of%20training%20and%20testing%20set/UNSW_NB15_training-set.csv [ 2 ] https://www.unsw.adfa.edu.au/unsw-canberra-cyber/cybersecurity/ADFA-NB15-Datasets/a%20part%20of%20training%20and%20testing%20set/UNSW_NB15_testing-set.csv

and trying to read and encode it... reader.zip

ben-strasser commented 3 years ago

Hi,

compile your program with -fsanitize=address. It will crash with an error message and stacktrace. There is a problem with encoder[ i ].name in encodeValue. Are you setting your null terminators for encoder[i].name? I do not see where. If not, that is your bug. Anyway, I a fairly certain that this is not a bug in the CSV library.

Best Regards Dr. Ben Strasser

lk-dll commented 3 years ago

Hi Ben,

thank you for your help, -fsanitize=address helped me, the problem wasn't null terminators, but I made a mistake and declared the number of lines for test_dataset( God is witness that I checked it thousand times ) and Call Stack pointed to CSVReader and LineReader, so sorry for that, but thank you anyway.

Best Regards