voikko / corevoikko

Libvoikko and essential linguistic resources
Other
89 stars 25 forks source link

Segmentation fault on Xubuntu 22.04 LTS #52

Closed ahomansikka closed 2 years ago

ahomansikka commented 2 years ago

This code causes a segmentation fault on Xubuntu 22.04 LTS

`#include

include <libvoikko/voikko.h>

int main() { const char *error;

VoikkoHandle *handle = voikkoInit (&error, "fi", "/usr/local/lib/voikko");

if (!handle) std::cout << "Pieleen meni." << std::endl;

std::cout << "Version " << voikkoGetVersion() << std::endl;

voikko_mor_analysis v = voikkoAnalyzeWordCstr (handle, "vappuasuidea"); const char a = voikko_mor_analysis_keys (*v);

for (size_t i = 0; a[i]; i++) { std::cout << a[i] << " " << voikko_mor_analysis_value_cstr (*v, a[i]) << std::endl; } return 0; }`

Compiling: g++ -g -Wall main.cc -o m -lvoikko

gdb says

`[Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Version 4.3.1

Program received signal SIGSEGV, Segmentation fault. libvoikko::morphology::Analysis::getKeys (this=0x0) at morphology/Analysis.cpp:122 122 return const_cast<const char **>(keys);`

ahomansikka commented 2 years ago

My fault. I can't read the documentation. voikkoAnalyzeWordCstr returns a pointer to a null terminated list of analysis result. So in the code *v is null if there are no results.