Low-level core library that forms the basis for projects such as GTK+ and GNOME.
Go to file
Sergei Trofimovich 6a8dce273a girffi.c: fix return value for g_callable_info_prepare_closure()
The initial failure was observed on `meld` against recently released
`libffi-3.4-rc1`. There `meld` crashes as:

```
$ meld
Segmentation fault (core dumped)

$ gdb --args /usr/bin/python3.9 /usr/bin/meld
(gdb) run
...
Thread 1 "python3.9" received signal SIGSEGV, Segmentation fault.
0x00007fffe9ac1ae8 in g_callable_info_free_closure (
  callable_info=0x555555d45990, closure=0x7fffe9e70c20)
    at ../gobject-introspection-1.68.0/girepository/girffi.c:428
428       g_free (wrapper->ffi_closure.cif->arg_types);
(gdb) bt
  callable_info=0x555555d45990, closure=0x7fffe9e70c20)
    at ../gobject-introspection-1.68.0/girepository/girffi.c:428
  data=0x555555d252d0)
    at ../pygobject-3.40.1/gi/pygi-closure.c:635
...
```

The bug here is in type mismatch between expected return value of
`g_callable_info_prepare_closure()` and actual value (executable
code pointer):

```c
ffi_closure * g_callable_info_prepare_closure(...) {
    gpointer exec_ptr;
    ...
    status = ffi_prep_closure_loc (&closure->ffi_closure, cif, callback, user_data, exec_ptr);

    return exec_ptr;
}
```

Note: `exec_ptr` is a code pointer that could be directly executed by
caller, like `((rt (*)(a1,a2))exec_ptr)(1,2);` It should never be wrapped
into an `ffi_closure*`, which is normally called via `ffi_call(closure, ...)`.

We see the problem when we try to free direct code pointer instead of
`ffi_closure()` as starting from libffi-3.4 executable trampoline and
`ffi_closure()` don't necessarily live in the same block:

    9ba559217b

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2021-11-23 23:04:26 +00:00
cmph Revert "Revert "Meson: Fix build when glib is built as subproject"" 2020-04-24 15:05:03 -04:00
cmph-bdz-test.c Drop calls to g_type_init() 2012-10-16 10:58:08 -04:00
docs.c docs: Remove everything not related to libgirepository and restructure. Fixes #244 2018-12-14 11:29:11 +01:00
gdump.c Add "final" class attribute 2021-08-05 16:24:23 +00:00
gi-dump-types.c meson: also build gi-dump-types on Windows 2020-05-19 19:39:34 +02:00
giarginfo.c docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
giarginfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
gibaseinfo.c baseinfo: don't abort when calling g_base_info_get_name() on a GITypeInfo. Fixes #96 2018-12-15 23:33:32 +00:00
gibaseinfo.h docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
gicallableinfo.c girepository: Fix leak in g_callable_info_invoke 2021-06-18 14:28:05 +00:00
gicallableinfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
giconstantinfo.c Use g_memdup2() with newer versions of GLib 2021-03-12 18:55:44 +00:00
giconstantinfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
gienuminfo.c docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
gienuminfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
gifieldinfo.c docs: Field offsets are in the units of bytes 2018-12-14 16:28:58 +01:00
gifieldinfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
gifunctioninfo.c Property accessors work for interfaces and objects 2021-08-05 17:47:29 +01:00
gifunctioninfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
giinterfaceinfo.c docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
giinterfaceinfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
ginvoke.c Initialise argument 2021-06-24 18:17:56 +00:00
giobjectinfo.c Add "final" class attribute 2021-08-05 16:24:23 +00:00
giobjectinfo.h Add "final" class attribute 2021-08-05 16:24:23 +00:00
gipropertyinfo.c Use a macro for the missing accessor sentinel value 2021-08-05 17:47:29 +01:00
gipropertyinfo.h Add introspection data for property accessors 2021-08-05 17:47:29 +01:00
giregisteredtypeinfo.c docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
giregisteredtypeinfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
girepository-private.h build: enable -Wredundant-decls 2018-07-29 18:57:03 +02:00
girepository.c Add missing nullable annotation to g_irepository_get_shared_library 2020-05-14 17:24:08 +02:00
girepository.h girepository: Return pointer array for interface cache 2019-06-20 11:54:10 -07:00
girffi.c girffi.c: fix return value for g_callable_info_prepare_closure() 2021-11-23 23:04:26 +00:00
girffi.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
girmodule.c girepository: Use constant time calculation for sections after Object fields 2015-10-10 17:41:24 -04:00
girmodule.h Add Emacs mode lines to C sources 2012-02-03 13:42:56 -05:00
girnode.c Improve readability of error message 2021-08-05 17:47:29 +01:00
girnode.h Add introspection data for property accessors 2021-08-05 17:47:29 +01:00
giroffsets.c docs: fix up reference docs a bit 2013-10-10 16:48:51 -04:00
girparser.c Add introspection data for property accessors 2021-08-05 17:47:29 +01:00
girparser.h Add Emacs mode lines to C sources 2012-02-03 13:42:56 -05:00
girwriter.c Add introspection data for property accessors 2021-08-05 17:47:29 +01:00
girwriter.h Add Emacs mode lines to C sources 2012-02-03 13:42:56 -05:00
gisignalinfo.c docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
gisignalinfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
gistructinfo.c structinfo: Fix offset in find_method() 2019-08-14 23:17:54 +02:00
gistructinfo.h docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
gitypeinfo.c girepository: Add GITypeInfo utility functions for storing values in pointers 2020-04-26 10:24:26 -07:00
gitypeinfo.h girepository: Add GITypeInfo utility functions for storing values in pointers 2020-04-26 10:24:26 -07:00
gitypelib-internal.h Use a macro for the missing accessor sentinel value 2021-08-05 17:47:29 +01:00
gitypelib.c girepository: Fix leak in prefix_with_context 2021-06-18 14:28:05 +00:00
gitypelib.h docs: Remove everything not related to libgirepository and restructure. Fixes #244 2018-12-14 11:29:11 +01:00
gitypes.h docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
giunioninfo.c docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
giunioninfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
giversion.c girepository: Add version macros and functions. Fixes #200 2018-12-16 12:51:58 +01:00
giversion.h.in girepository: Add version macros and functions. Fixes #200 2018-12-16 12:51:58 +01:00
giversionmacros.h Add version macros for 1.70 2021-08-05 16:24:23 +00:00
givfuncinfo.c docs: fix gtk-doc warnings and update version infos 2018-12-09 18:26:26 +01:00
givfuncinfo.h girepository: Add Header for Version Macros 2014-08-15 09:45:41 +08:00
gthash-test.c Drop calls to g_type_init() 2012-10-16 10:58:08 -04:00
gthash.c build: enable -Wtype-limits 2018-07-29 18:57:03 +02:00
meson.build Make test suite work with cross-related options 2021-05-23 12:56:21 -04:00