macOS: programs using g_get_os_info() are crashing
vmagnin opened this issue · 2 comments
vmagnin commented
Describe the bug
In gtk-fortran 4.2.0, examples/tests.f90
, examples/bazaar.f90
and src/gtk-fortran.f90
are crashing (segmentation fault), only on macOS.
Your system:
- OS version: macOS 10.15.7
- Compiler version: gfortran
- GTK branch: gtk4, gtk-fortran 4.2.0
vmagnin commented
The problem comes from the GLib g_get_os_info()
function:
call c_f_string_copy(g_get_os_info("PRETTY_NAME"//c_null_char), os_string)
The GLib doc (https://docs.gtk.org/glib/func.get_os_info.html) says it returns NULL if this information is not provided. That is the case under macOS.
vmagnin commented
Solution:
type(c_ptr) :: ret
ret = g_get_os_info("PRETTY_NAME"//c_null_char)
if (c_associated(ret)) then
call c_f_string_copy(ret, os_string)
else
os_string = "?"
end if