I tried to pinpoint the cause of error in pmoses.cpp and reduced the
code to just a few lines:
#include "PhraseDictionary.h"
using namespace std;
using namespace Moses;
int main (int argc, char *argv[]) {
vector<FactorType> input, output;
vector<float> weight;
string filePath = "/path/to/phrase-table";
weight.push_back(1);
weight.push_back(1);
weight.push_back(1);
weight.push_back(1);
weight.push_back(1);
const PhraseDictionaryFeature* feature = new
PhraseDictionaryFeature(weight.size(), 0, input, output, filePath,
weight, 20);
}
I compile it with:
g++ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -g -Lsrilm/lib/i686-m64
-Lirstlm/lib/x86_64 -Lmoses/moses/src/.libs -o pmoses -I.
-Imoses/moses/src pmoses.cpp -lmoses -loolm -ldstruct -lmisc -lirstlm
-lz -lboost_thread-mt
Running it I get:
> pmoses
*** glibc detected *** pmoses: malloc(): memory corruption:
0x0000000001793a10 ***
======= Backtrace: =========
/lib/libc.so.6[0x7f6d63425dd6]
/lib/libc.so.6[0x7f6d63428c4e]
/lib/libc.so.6(__libc_malloc+0x6e)[0x7f6d6342a82e]
/usr/lib/libstdc++.so.6(_Znwm+0x1d)[0x7f6d63c8164d]
pmoses[0x40bd26]
pmoses[0x40bb2f]
pmoses[0x40b5c9]
pmoses[0x40a140]
pmoses[0x408ae4]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f6d633ceabd]
pmoses[0x4088a9]
Trying to trace the cause with valgrind, I get:
> valgrind pmoses
==31421== Memcheck, a memory error detector
==31421== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==31421== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for
copyright info
==31421== Command: pmoses
==31421==
==31421== Invalid write of size 8
==31421== at 0x40BD15:
boost::detail::shared_count::shared_count<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data*,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>
>(boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data*,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>)
(shared_count.hpp:110)
==31421== by 0x40BB2E:
boost::shared_ptr<boost::detail::tss_cleanup_function>::shared_ptr<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>
>(boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data*,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>)
(shared_ptr.hpp:194)
==31421== by 0x40B5C8:
boost::thread_specific_ptr<Moses::PhraseDictionary>::thread_specific_ptr()
(tss.hpp:66)
==31421== by 0x40A13F:
Moses::PhraseDictionaryFeature::PhraseDictionaryFeature(unsigned long,
unsigned int, std::vector<unsigned long, std::allocator<unsigned long> >
const&, std::vector<unsigned long, std::allocator<unsigned long> >
const&, std::string const&, std::vector<float, std::allocator<float> >
const&, unsigned long) (PhraseDictionary.cpp:52)
==31421== by 0x408AE3: main (pmoses.cpp:18)
==31421== Address 0x6197108 is 0 bytes after a block of size 136 alloc'd
==31421== at 0x4C2596C: operator new(unsigned long)
(vg_replace_malloc.c:220)
==31421== by 0x408AA4: main (pmoses.cpp:18)
==31421==
==31421== Invalid write of size 8
==31421== at 0x40BD49:
boost::detail::shared_count::shared_count<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data*,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>
>(boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data*,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>)
(shared_count.hpp:123)
==31421== by 0x40BB2E:
boost::shared_ptr<boost::detail::tss_cleanup_function>::shared_ptr<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>
>(boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data*,
boost::detail::do_heap_delete<boost::thread_specific_ptr<Moses::PhraseDictionary>::delete_data>)
(shared_ptr.hpp:194)
==31421== by 0x40B5C8:
boost::thread_specific_ptr<Moses::PhraseDictionary>::thread_specific_ptr()
(tss.hpp:66)
==31421== by 0x40A13F:
Moses::PhraseDictionaryFeature::PhraseDictionaryFeature(unsigned long,
unsigned int, std::vector<unsigned long, std::allocator<unsigned long> >
const&, std::vector<unsigned long, std::allocator<unsigned long> >
const&, std::string const&, std::vector<float, std::allocator<float> >
const&, unsigned long) (PhraseDictionary.cpp:52)
==31421== by 0x408AE3: main (pmoses.cpp:18)
==31421== Address 0x6197108 is 0 bytes after a block of size 136 alloc'd
==31421== at 0x4C2596C: operator new(unsigned long)
(vg_replace_malloc.c:220)
==31421== by 0x408AA4: main (pmoses.cpp:18)
==31421==
Can't read /path/to/phrase-table
==31421==
==31421== HEAP SUMMARY:
==31421== in use at exit: 618 bytes in 8 blocks
==31421== total heap usage: 28 allocs, 20 frees, 6,362 bytes allocated
==31421==
==31421== LEAK SUMMARY:
==31421== definitely lost: 272 bytes in 2 blocks
==31421== indirectly lost: 0 bytes in 0 blocks
==31421== possibly lost: 46 bytes in 1 blocks
==31421== still reachable: 300 bytes in 5 blocks
==31421== suppressed: 0 bytes in 0 blocks
==31421== Rerun with --leak-check=full to see details of leaked memory
==31421==
==31421== For counts of detected and suppressed errors, rerun with: -v
==31421== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4)
Nothing changes if I give a real filePath.
Can someone help, please?
-- Attardi
_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support