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

Deleting a MultiFileIndex is not possible #14

Open
AlexanderFabisch opened this issue May 12, 2017 · 2 comments
Open

Deleting a MultiFileIndex is not possible #14

AlexanderFabisch opened this issue May 12, 2017 · 2 comments

Comments

@AlexanderFabisch
Copy link

While running the following program, it hangs at delete multiIndex; and won't finish. Valgrind gives me the following error:

==13922== Conditional jump or move depends on uninitialised value(s)
==13922== at 0x4E8DFA0: pocolog_cpp::MultiFileIndex::~MultiFileIndex() (MultiFileIndex.cpp:24)
==13922== by 0x4058CE: main (in /home/dfki.uni-bremen.de/afabisch/tmp/test/tools/pocolog2hdf5/build/pocolog2hdf5)

#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
#include <pocolog_cpp/MultiFileIndex.hpp>
#include <pocolog_cpp/Stream.hpp>
#include <pocolog_cpp/InputDataStream.hpp>


std::vector<std::string> getFilenames(int argc, char *argv[])
{
    const int numFiles = argc - 1;
    std::vector<std::string> filenames(numFiles);
    for(int i = 0; i < numFiles; i++)
        filenames[i] = argv[i + 1];
    return filenames;
}

int main(int argc, char *argv[])
{
    if(argc == 1)
    {
        std::cerr << "No logfile given" << std::endl;
        return EXIT_FAILURE;
    }

    pocolog_cpp::MultiFileIndex* multiIndex = new pocolog_cpp::MultiFileIndex();

    std::vector<std::string> filenames = getFilenames(argc, argv);
    multiIndex->createIndex(filenames);
    const size_t numSamples = multiIndex->getSize();

    std::vector<pocolog_cpp::Stream*> streams = multiIndex->getAllStreams();
    const size_t numStreams = streams.size();
    std::vector<pocolog_cpp::InputDataStream*> dataStreams(numStreams);
    for(size_t i = 0; i < numStreams; i++)
        dataStreams[i] = dynamic_cast<pocolog_cpp::InputDataStream*>(streams[i]);

    std::cout << numSamples << " samples X " << numStreams << std::endl;

    for(size_t t = 0; t < numSamples; t++)
    {
        for(size_t i = 0; i < numStreams; i++)
        {
            std::cout << "t = " << t << ", column = " << i << std::endl;
            std::cout << dataStreams[i]->getName() << std::endl;
        }
    }

    delete multiIndex;
    std::cout << "deleted" << std::endl;

    return EXIT_SUCCESS;
}
@AlexanderFabisch
Copy link
Author

@hemker Do you have an idea?

@AlexanderFabisch
Copy link
Author

OK, I solved this issue for me: pocolog_cpp must be compiled with C++11, e.g. set(CMAKE_CXX_STANDARD 11).

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

No branches or pull requests

1 participant