ilius / ayandict

AyanDict - a simple multi-lingual cross-platform offline dictionary based on Qt and written in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: runtime error: invalid memory address or nil pointer dereference on macos

homocomputeris opened this issue · comments

I downloaded the release version for darwin to use on macos 13. It launched fine, but crashed while searching for a word.
Maybe because the paths seem to be hardcoded.

$ ./ayandict-darwin-x86_64
looking for qtbox in: /Users/user/Downloads/qtbox
final qtbox location: /Users/user/Downloads/qtbox
2023/04/24 19:01:37 Initializing "/Users/user/Documents/GoldenDict/Sr/Wiktionary (Sr-En)/Wiktionary (Sr-En).ifo"
2023/04/24 19:01:37 gzip: invalid checksum
2023/04/24 19:01:37 Loading dictionaries took 612.831179ms
2023/04/24 19:01:41 dictName="Wiktionary (Sr-En)", ds=<nil>
2023/04/24 19:01:50 Search index loop took 25.671164ms for "mrlja" on Wiktionary (Sr-En)
2023/04/24 19:01:50 LookupHTML took 25.708861ms for "mrlja"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1f967c6]

goroutine 8 [running]:
github.com/ilius/ayandict/pkg/stardict.(*Dict).GetSequence(0xc005de5748?, 0x1fa7dec?, 0xc00009a7e0?)
	C:/Users/Saeed/go/src/github.com/ilius/ayandict/pkg/stardict/dict_unix.go:13 +0x26
github.com/ilius/ayandict/pkg/stardict.(*Dictionary).Search.func2()
	C:/Users/Saeed/go/src/github.com/ilius/ayandict/pkg/stardict/dictionary.go:159 +0x31
github.com/ilius/ayandict/pkg/stardict.(*QueryResultImp).DefinitionsHTML(0xc005f315f0)
	C:/Users/Saeed/go/src/github.com/ilius/ayandict/pkg/stardict/stardict.go:62 +0x62
github.com/ilius/ayandict/pkg/application.(*ResultListWidget).OnActivate(0xc004558370, 0x0?)
	C:/Users/Saeed/go/src/github.com/ilius/ayandict/pkg/application/query.go:118 +0x6a
github.com/ilius/ayandict/pkg/application.NewResultListWidget.func1(0x0?)
	C:/Users/Saeed/go/src/github.com/ilius/ayandict/pkg/application/query.go:50 +0x32
reflect.Value.call({0x21557a0?, 0xc0045786d0?, 0x28267c0?}, {0x2441eea, 0x4}, {0xc005dd2138, 0x1, 0x1106fa5?})
	C:/Program Files/Go/src/reflect/value.go:584 +0x8c5
reflect.Value.Call({0x21557a0?, 0xc0045786d0?, 0xc004cfcfa8?}, {0xc005dd2138?, 0x215f060?, 0x0?})
	C:/Program Files/Go/src/reflect/value.go:368 +0xbc
github.com/therecipe/qt/internal.handleCallback({0xc00527cd45, 0x2e})
	C:/Users/Saeed/go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:73 +0x2fd
github.com/therecipe/qt/internal.syncCallbackHandler({0xc00527cd45?, 0x0?})
	C:/Users/Saeed/go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:113 +0x1e
created by github.com/therecipe/qt/internal.InitProcess.func3
	C:/Users/Saeed/go/pkg/mod/github.com/therecipe/qt@v0.0.0-20200904063919-c0c124a5770d/internal/internal.go:409 +0x1aa

Config is default. Only the dictionary path is changed:

directory_list = ["/Users/user/Documents/GoldenDict/Sr"]
style = ""
article_style = ""
font_family = ""
font_size = 0
search_on_type = false
search_on_type_min_length = 3
header_template = "<b><font color='#55f'>{{.DictName}}</font></b>\n<font color='#777'> [Score: %{{.Score}}]</font>\n<div dir=\"ltr\" style=\"font-size: xx-large;font-weight:bold;\">\n{{ index .Terms 0 }}\n</div>\n{{range slice .Terms 1}}\n<span dir=\"ltr\" style=\"font-size: large;font-weight:bold;\">\n\t<span style=\"color:#ff0000;font-weight:bold;\"> | </span>\n\t{{ . }}\n</span>\n{{end}}"
history_disable = false
history_auto_save = true
history_max_size = 100
most_frequent_disable = false
most_frequent_auto_save = true
most_frequent_max_size = 100
favorites_auto_save = true
max_results_total = 40
audio = true
embed_external_stylesheet = false
popup_style_str = "border: 1px solid red; background-color: #333; color: white"
wheel_zoom_factor = 1.1
article_arrow_keys = false

[color_mapping]

Thanks.
This bug has been fixed.

Can you uncompress the dict.dz file with dictunzip tool?

Actually dict.dz file is not going to work (I have only fixed the panic), so you have to uncompress it.

It works with uncompressed dictionary. Thanks!

The fix in 2.0 works. Thanks a lot!