Exception on using Vte
kugel- opened this issue · comments
The following code throws an exception, even though I think the code ought to be fine. Can you guide me what's wrong here? Does it have something to do with the fact that vte_terminal_feed() is passed a const gchar *
that's meant to hold binary data (not a nul terminated string) plus a separate length parameter?
require 'gir_ffi-gtk3'
Gtk.init
GObjectIntrospection::IRepository.default.require("Vte", "2.91")
GirFFI.setup(:Vte, '2.91')
vte = Vte::Terminal.new
win = Gtk::Window.new(:toplevel)
win.add(vte)
win.show_all
vte.feed("foo")
Gtk.main
=>
/usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/in_pointer.rb:108:in `put_array_of_uint8': Memory access offset=0 size=5205862 is out of bounds (IndexError)
from /usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/in_pointer.rb:108:in `block in from_basic_type_array'
from /usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/in_pointer.rb:106:in `tap'
from /usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/in_pointer.rb:106:in `from_basic_type_array'
from /usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/in_pointer.rb:15:in `from_array'
from /usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/sized_array.rb:104:in `from_enumerable'
from /usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/sized_array.rb:70:in `from'
from (eval):4:in `feed'
from /usr/lib/ruby/gems/2.3.0/gems/gir_ffi-0.11.0/lib/gir_ffi/class_base.rb:25:in `setup_and_call'
from (eval):2:in `feed'
from /tmp/test.rb:15:in `<main>'
Here's the gir for vte_terminal_feed():
<method name="feed" c:identifier="vte_terminal_feed">
<doc xml:space="preserve">Interprets @data as if it were data received from a child process. This
can either be used to drive the terminal without a child process, or just
to mess with your users.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<instance-parameter name="terminal" transfer-ownership="none">
<doc xml:space="preserve">a #VteTerminal</doc>
<type name="Terminal" c:type="VteTerminal*"/>
</instance-parameter>
<parameter name="data"
transfer-ownership="none"
nullable="1"
allow-none="1">
<doc xml:space="preserve">a string in the terminal's current encoding</doc>
<array length="1" zero-terminated="0" c:type="char*">
<type name="guint8"/>
</array>
</parameter>
<parameter name="length" transfer-ownership="none">
<doc xml:space="preserve">the length of the string, or -1 to use the full length or a nul-terminated string</doc>
<type name="gssize" c:type="gssize"/>
</parameter>
</parameters>
</method>