After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 698175 - nm_connection_need_secrets and nm_setting_need_secrets crash through introspection
nm_connection_need_secrets and nm_setting_need_secrets crash through introspe...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: API
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-04-17 05:12 UTC by Martin Pitt
Modified: 2013-04-19 14:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
reproducer (519 bytes, text/x-python)
2013-04-17 05:12 UTC, Martin Pitt
  Details
libnm-glib: Fix transfer annotations of nm_{connection,setting}_need_secrets() (3.83 KB, patch)
2013-04-17 05:20 UTC, Martin Pitt
none Details | Review
libnm-glib: Fix transfer annotations of nm_{connection,setting}_need_secrets() (3.83 KB, patch)
2013-04-17 05:54 UTC, Martin Pitt
committed Details | Review
libnm-glib: Fix transfer annotations of nm_{connection,setting}_need_secrets() (3.82 KB, patch)
2013-04-19 13:47 UTC, Martin Pitt
committed Details | Review
Use %NULL macro in doc strings (36.63 KB, patch)
2013-04-19 13:49 UTC, Martin Pitt
committed Details | Review

Description Martin Pitt 2013-04-17 05:12:49 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]
Comment 1 Martin Pitt 2013-04-17 05:20:55 UTC
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.
Comment 2 Martin Pitt 2013-04-17 05:54:11 UTC
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 3 Dan Winship 2013-04-19 13:20:07 UTC
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
Comment 4 Martin Pitt 2013-04-19 13:47:17 UTC
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.
Comment 5 Martin Pitt 2013-04-19 13:49:24 UTC
Created attachment 241903 [details] [review]
Use %NULL macro in doc strings

This replaces all occurrences of "NULL" in docstrings with "%NULL".