NiuTrans / NiuTrans.SMT

NiuTrans.SMT is an open-source statistical machine translation system developed by a joint team from NLP Lab. at Northeastern University and the NiuTrans Team. The NiuTrans system is fully developed in C++ language. So it runs fast and uses less memory. Currently it supports phrase-based, hierarchical phrase-based and syntax-based (string-to-tree, tree-to-string and tree-to-tree) models for research-oriented studies.
GNU General Public License v2.0
148 stars 36 forks source link

Segmentation fault when using NiuTrans.Decoder #9

Closed Caleblyx closed 1 year ago

Caleblyx commented 1 year ago

Hi, I am using the latest version of NiuTrans.SMT, and while following the Quick Walkthrough of the user manual, I encountered the following issue: image I am running this on Centos Stream 8. Please do advise. Thank you!

llccd commented 1 year ago

Same issue on Debian with GCC 12. I changed code as following and it works.

diff --git a/src/NiuTrans.Decoder/DataCheck.cpp b/src/NiuTrans.Decoder/DataCheck.cpp
index 94b888f..5c39329 100644
--- a/src/NiuTrans.Decoder/DataCheck.cpp
+++ b/src/NiuTrans.Decoder/DataCheck.cpp
@@ -34,7 +34,7 @@

 namespace smt{

-bool DataChecker::CheckInputSentences(const char * fn, bool forTuning, int nref)
+void DataChecker::CheckInputSentences(const char * fn, bool forTuning, int nref)
 {
        char * line = new char[MAX_LINE_LENGTH];
        char * msg = new char[1024];
diff --git a/src/NiuTrans.Decoder/DataCheck.h b/src/NiuTrans.Decoder/DataCheck.h
index afed948..fe0bafe 100644
--- a/src/NiuTrans.Decoder/DataCheck.h
+++ b/src/NiuTrans.Decoder/DataCheck.h
@@ -50,7 +50,7 @@ public:
        ~DataChecker(){};

 public:
-       static bool CheckInputSentences(const char * fn, bool forTuning, int nref);
+       static void CheckInputSentences(const char * fn, bool forTuning, int nref);
        static bool CheckSentence(const char * sent, char * msg);
        static bool CheckModelFiles(Configer * configer);

diff --git a/src/NiuTrans.Decoder/TrainingAndDecoding.cpp b/src/NiuTrans.Decoder/TrainingAndDecoding.cpp
index b8a8ec1..eabcabc 100644
--- a/src/NiuTrans.Decoder/TrainingAndDecoding.cpp
+++ b/src/NiuTrans.Decoder/TrainingAndDecoding.cpp
@@ -388,7 +388,7 @@ void OurSystem::InitForDecodingForServicecMode(int threadNum)

 void OurSystem::ReadTestSentences(const char * testfn)
 {
-   char line[MAX_LINE_LENGTH/4] = "";
+   char line[MAX_LINE_LENGTH] = "";

    /* load test sentences */
     FILE * file = fopen(testfn, "rb");
liyinqiao2012 commented 1 year ago

Hi, I am using the latest version of NiuTrans.SMT, and while following the Quick Walkthrough of the user manual, I encountered the following issue: image I am running this on Centos Stream 8. Please do advise. Thank you!

We have fixed this bug in the latest version. Please check it out. Many thanks to @llccd .