Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault in csv::internals::ThreadSafeDeque<csv::CSVRow>::~ThreadSafeDeque #167

Closed
tonjif opened this issue May 16, 2021 · 2 comments
Assignees
Labels

Comments

@tonjif
Copy link

tonjif commented May 16, 2021

I have been using CSVReader in a function like this:

void load_trajectory_dataset(std::string& trajectory_dataset_path, TrajectoryDataset& trajectory_dataset) {
    csv::CSVFormat format;
    format.delimiter(',')
        .header_row(0);
    
    /* Create Reader */
    csv::CSVReader reader(trajectory_dataset_path, format);
    
    /* Value for each row */
    integer_type user;
    floating_point_type latitude, longitude, timestamp;
    
    /* Iterate all rows */
    for (csv::CSVRow& row: reader) {
        user = row["user"].get<integer_type>();
        latitude = row["latitude"].get<floating_point_type>();
        longitude = row["longitude"].get<floating_point_type>();
        timestamp = row["timestamp"].get<floating_point_type>();
        
        /* Save information */
        trajectory_dataset[user].emplace_back(latitude, longitude, timestamp);
    }
}

When returning from this function, a Segmentation Fault is encountered in the destructor of csv::internals::ThreadSafeDequecsv::CSVRow, csv::internals::ThreadSafeDequecsv::CSVRow::~ThreadSafeDeque. The LLDB back trace is as follows:

(lldb) bt
* thread #1, name = 'a.out', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x00000000004179e8 a.out`csv::internals::ThreadSafeDeque<csv::CSVRow>::~ThreadSafeDeque(this=0x00000000006c2aa0) at csv.hpp:5903:15
    frame #2: 0x00000000004228ab a.out`std::default_delete<csv::internals::ThreadSafeDeque<csv::CSVRow> >::operator(this=0x00007fffffffc600, __ptr=0x00000000006c2aa0)(csv::internals::ThreadSafeDeque<csv::CSVRow>*) const at unique_ptr.h:81:2
    frame #3: 0x00000000004146bd a.out`std::unique_ptr<csv::internals::ThreadSafeDeque<csv::CSVRow>, std::default_delete<csv::internals::ThreadSafeDeque<csv::CSVRow> > >::~unique_ptr(this=0x00007fffffffc600) at unique_ptr.h:292:4
    frame #4: 0x0000000000408af0 a.out`csv::CSVReader::~CSVReader(this=0x00007fffffffc590) at csv.hpp:6320:9
    frame #5: 0x0000000000405979 a.out`load_trajectory_dataset(trajectory_dataset_path=error: summary string parsing error, trajectory_dataset=0x00000000006a4740) at input_output.hpp:34:1
    frame #6: 0x00000000004065ad a.out`main(argc=5, argv=0x00007fffffffce08) at calculate_and_write_k_nn_trajectory_similarity.cpp:127:6
    frame #7: 0x000000000050ef60 a.out`__libc_start_main + 1168
    frame #8: 0x000000000040532e a.out`_start + 46

I was wondering whether pointers were used in csv::internals::ThreadSafeDeque, but I couldn't find any when I read csv::internals::ThreadSafeDeque at csv.hpp:5903:15 . What else could be the cause of the invalid address?

@vincentlaucsb vincentlaucsb self-assigned this May 24, 2021
@vincentlaucsb
Copy link
Owner

Thanks for reporting this. ThreadSafeDeque is a generic container, and in this case it is used to hold CSVRow objects, which do contain pointers.

@vincentlaucsb
Copy link
Owner

vincentlaucsb commented May 19, 2024

Closing because nobody else has reported this issue. A segfault involving 0x0 during object destruction in an object that uses the implicitly-defined C++ destructor is unlikely a problem with this library's code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants