Skip to content

Instantly share code, notes, and snippets.

@karlnapf
Created May 2, 2013 14:20
Show Gist options
  • Save karlnapf/5502520 to your computer and use it in GitHub Desktop.
Save karlnapf/5502520 to your computer and use it in GitHub Desktop.
Minimal program that has problem with streaming features
#include <shogun/io/streaming/StreamingAsciiFile.h>
#include <shogun/features/streaming/StreamingSparseFeatures.h>
using namespace shogun;
int main(int argc, char *argv[])
{
init_shogun();
CStreamingAsciiFile *file=new CStreamingAsciiFile("trivial-crash-example.dat");
SG_REF(file);
CStreamingSparseFeatures<float64_t> *stream_features=
new CStreamingSparseFeatures<float64_t>(file, true, 1024);
SG_REF(stream_features);
stream_features->start_parser();
while (stream_features->get_next_example())
{
// first try: this one leads to double-free in SG_UNREF(stream)
stream_features->get_vector();
stream_features->release_example();
}
stream_features->end_parser();
// double free
SG_UNREF(stream_features);
SG_UNREF(file);
exit_shogun();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment