GNOME Bugzilla – Bug 698175
nm_connection_need_secrets and nm_setting_need_secrets crash through introspection
Last modified: 2013-04-19 14:09:34 UTC
Created attachment 241709 [details] reproducer Trying to call nm_connection_need_secrets() or nm_setting_need_secrets() from through introspection (using Python here) crashes as soon as there is any actual entry: $ GI_TYPELIB_PATH=libnm-util:libnm-glib python3 ~/t.py ----- device wlan0 ----- Connection: /org/freedesktop/NetworkManager/Settings/1 Connection type: <class 'gi.repository.NMClient.RemoteConnection'> wireless-security setting: <SettingWirelessSecurity object at 0x7fcf4228ac80 (NMSettingWirelessSecurity at 0x24e20d0)> *** Error in `python3': munmap_chunk(): invalid pointer: 0x00007fcf4438f668 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x7f576)[0x7fcf47220576] /usr/lib/python3/dist-packages/gi/_gi.cpython-33m-x86_64-linux-gnu.so(+0x1c565)[0x7fcf4650f565] /usr/lib/python3/dist-packages/gi/_gi.cpython-33m-x86_64-linux-gnu.so(+0x1bef3)[0x7fcf4650eef3] /usr/lib/python3/dist-packages/gi/_gi.cpython-33m-x86_64-linux-gnu.so(+0x15561)[0x7fcf46508561] python3(PyEval_EvalFrameEx+0x6f8e)[0x4ab43e] python3(PyEval_EvalCodeEx+0x576)[0x4b00e6] python3(PyEval_EvalFrameEx+0x5779)[0x4a9c29] python3(PyEval_EvalCodeEx+0x167)[0x4afcd7] python3(PyEval_EvalCode+0x3b)[0x54b53b] python3[0x54724e] python3(PyRun_FileExFlags+0x9a)[0x45aee6] python3(PyRun_SimpleFileExFlags+0x377)[0x45b2c2] python3(Py_Main+0xab0)[0x45d840] python3(main+0xd7)[0x4806c7] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fcf471c2ea5] python3[0x533765]
Created attachment 241710 [details] [review] libnm-glib: Fix transfer annotations of nm_{connection,setting}_need_secrets() This fixes the annotations and documentation, so this works now: $ GI_TYPELIB_PATH=libnm-util:libnm-glib python3 ~/t.py ----- device wlan0 ----- Connection: /org/freedesktop/NetworkManager/Settings/1 Connection type: <class 'gi.repository.NMClient.RemoteConnection'> wireless-security setting: <SettingWirelessSecurity object at 0x7fbc93e3bd20 (NMSettingWirelessSecurity at 0x17278d0)> wireless-security setting need_secrets: ['psk'] connection need_secrets: ('802-11-wireless-security', ['psk']) Connection: /org/freedesktop/NetworkManager/Settings/0 Connection type: <class 'gi.repository.NMClient.RemoteConnection'> wireless-security setting: <SettingWirelessSecurity object at 0x7fbc93e3bd70 (NMSettingWirelessSecurity at 0x1727820)> wireless-security setting need_secrets: ['psk'] connection need_secrets: ('802-11-wireless-security', ['psk']) Alternatively, if the method is really supposed to return a (transfer full) object, all the need_secrets() implementations need to use strdup(). But it's certainly more efficient as it is now.
Created attachment 241711 [details] [review] libnm-glib: Fix transfer annotations of nm_{connection,setting}_need_secrets() This fixes the duplicate "with" in the docstring, and reformats the "returns" paragraph to not use an overly long line.
Comment on attachment 241711 [details] [review] libnm-glib: Fix transfer annotations of nm_{connection,setting}_need_secrets() >- * @hints: (out callee-allocates) (element-type utf8) (allow-none) (transfer full): >+ * @hints: (out callee-allocates) (element-type utf8) (allow-none) (transfer container): Is that "callee-allocates" actually needed? It seems like it ought to figure that out by default, in which case it would be nicer to not specify it explicitly. > * the address of a pointer to a #GPtrArray, initialized to NULL, which on %NULL ok to commit, with the "callee-allocates" removed if possible
Created attachment 241902 [details] [review] libnm-glib: Fix transfer annotations of nm_{connection,setting}_need_secrets() No, "callee-allocates" is the default and does not need to be specified explicitly. I'll attach a separate patch for %NULL as that's unrelated and quite a big one.
Created attachment 241903 [details] [review] Use %NULL macro in doc strings This replaces all occurrences of "NULL" in docstrings with "%NULL".