eyelash / xi-gtk

a GTK front-end for the Xi editor
Apache License 2.0
355 stars 23 forks source link

xi-gtk freezes when opening files whose names are invalid utf8, and have invalid utf8 #44

Open mateon1 opened 6 years ago

mateon1 commented 6 years ago

How to reproduce:

  1. Open xi-gtk
  2. Open a file whose filename is invalid utf8, which contains invalid utf8, so xi-core exits. in my case, the filename is: (hex) 20 ed 96 4f 56 (or escaped): " \xed\x96OV" the file is a corrupt stack trace that contains some non-utf8 gibberish, but any binary file should work.
  3. After xi-core exits, xi-gtk enters an infinite loop printing error messages to the console

Stdout/stderr:

starting plugins for view-id-1
starting plugins for view-id-3
xi-core exited with error:
Io(Error { repr: Custom(Custom { kind: InvalidData, error: StringError("stream did not contain valid UTF-8") }) })

(xi-gtk:8440): Json-CRITICAL **: json_parser_load_from_data: assertion 'data != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_node_get_object: assertion 'JSON_NODE_IS_VALID (node)' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_has_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_get_string_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_get_object_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_parser_load_from_data: assertion 'data != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_node_get_object: assertion 'JSON_NODE_IS_VALID (node)' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_has_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_get_string_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_get_object_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_parser_load_from_data: assertion 'data != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_node_get_object: assertion 'JSON_NODE_IS_VALID (node)' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_has_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_get_string_member: assertion 'object != NULL' failed

(xi-gtk:8440): Json-CRITICAL **: json_object_get_object_member: assertion 'object != NULL' failed

The spam of Json-CRITICAL errors continues forever. The only solution is to kill xi-gtk.

eyelash commented 6 years ago

The infinite loop should be fixed in 39d55592e67f00d85ba737c7c3fed69022100340. Filenames that are invalid UTF-8 are hard to support with the current architecture as the front-end communicates with the core through JSON and the JSON has to be valid UTF-8. Support for files whose content uses a non-UTF-8 encoding is something that should be handled in the core.

cmyr commented 6 years ago

Support for non-utf8 filenames would be possible if annoying, but is probably something xi-core should support eventually. It means paths are going to need to be sent in base64 or something. I'd welcome an issue in xi-core but I don't expect to get around to it in a hurry.

Better support for non-utf8 encodings is definitely important, and there's been some very preliminary groundwork in this direction in core. I also don't think there's a real issue up for that, so again file in xi-core if you like @mateon1 :)

eyelash commented 6 years ago

See also google/xi-editor#796