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 625438 - test_gio.TestContentTypeGuess.testFromContents fails on x86-64
test_gio.TestContentTypeGuess.testFromContents fails on x86-64
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gio
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2010-07-27 21:25 UTC by Simon van der Linden
Modified: 2010-07-30 13:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
use strlen instead of z# to get the length of an argument (1.35 KB, patch)
2010-07-30 10:45 UTC, johnp
rejected Details | Review
make sure we parse parameters to python object vars not glib vars (2.63 KB, patch)
2010-07-30 10:48 UTC, johnp
accepted-commit_now Details | Review
use strlen instead of z# to get the length of an argument (1.07 KB, patch)
2010-07-30 12:46 UTC, johnp
none Details | Review
check if z# needs an int or Py_ssize_t (876 bytes, patch)
2010-07-30 12:49 UTC, johnp
accepted-commit_now Details | Review

Description Simon van der Linden 2010-07-27 21:25:15 UTC
testFromContents (test_gio.TestContentTypeGuess) ... 
Program received signal SIGSEGV, Segmentation fault.
cache_magic_matchlet_compare_to_data (cache=0x8a4d40, offset=<value optimized out>, data=0x2aaa00000000, len=13)
    at xdgmimecache.c:199
199		      if (((unsigned char *)cache->buffer)[data_offset + j] != ((unsigned char *) data)[j + i])

  • #0 cache_magic_matchlet_compare_to_data
    at xdgmimecache.c line 199
  • #1 cache_magic_matchlet_compare
    at xdgmimecache.c line 225
  • #2 cache_magic_compare_to_data
    at xdgmimecache.c line 257
  • #3 cache_magic_lookup_data
    at xdgmimecache.c line 293
  • #4 cache_get_mime_type_for_data
    at xdgmimecache.c line 710
  • #5 g_content_type_guess
    at gcontenttype.c line 938
  • #6 _wrap_g_content_type_guess
    at gio.override line 349

Comment 1 johnp 2010-07-30 09:29:15 UTC
data is an invalid pointer in the override for some reason.  Doing the same test from C works.  

Issue with PyArg_ParseTupleAndKeywords?
Comment 2 johnp 2010-07-30 09:33:58 UTC
The "|zz#i:g_content_type_guess" signature fails for z# (get the string and length).  Removing the # and using strlen to get the length works.
Comment 3 johnp 2010-07-30 10:45:59 UTC
Created attachment 166821 [details] [review]
use strlen instead of z# to get the length of an argument

* for some reason PyArg_ParseTupleAndKeywords returns an invalid pointer
  for |z# when the parameter is not supplied (should stay NULL)
* use |z and then call strlen on the parameter if it is not NULL
Comment 4 johnp 2010-07-30 10:48:15 UTC
Created attachment 166822 [details] [review]
make sure we parse parameters to python object vars not glib vars

* py_flags was already set up but due to a typo &flags was being passed
  instead
Comment 5 Simon van der Linden 2010-07-30 11:05:52 UTC
Review of attachment 166821 [details] [review]:

We can still use z#. The problem is that data_size must be a Py_ssize_t (a machine word) rather than an int. I don't know whether we want compatibility with Python 2.4 or not. If so, we need to check that PY_SSIZE_T_CLEAN is defined, and use an int otherwise.
Comment 6 Tomeu Vizoso 2010-07-30 12:35:51 UTC
(In reply to comment #5)
> Review of attachment 166821 [details] [review]:
> 
> We can still use z#. The problem is that data_size must be a Py_ssize_t (a
> machine word) rather than an int. I don't know whether we want compatibility
> with Python 2.4 or not. If so, we need to check that PY_SSIZE_T_CLEAN is
> defined, and use an int otherwise.

Will this still work if data contains binary data instead of text?
Comment 7 johnp 2010-07-30 12:46:31 UTC
Created attachment 166829 [details] [review]
use strlen instead of z# to get the length of an argument

* for some reason PyArg_ParseTupleAndKeywords returns an invalid pointer
  for |z# when the parameter is not supplied (should stay NULL)
* use |z and then call strlen on the parameter if it is not NULL
Comment 8 johnp 2010-07-30 12:49:01 UTC
Created attachment 166830 [details] [review]
check if z# needs an int or Py_ssize_t
Comment 9 Simon van der Linden 2010-07-30 13:02:19 UTC
Review of attachment 166822 [details] [review]:

Thanks.
Comment 10 Simon van der Linden 2010-07-30 13:02:29 UTC
Review of attachment 166830 [details] [review]:

Thanks!
Comment 11 Simon van der Linden 2010-07-30 13:03:30 UTC
Tomeu, I don't get your question. Can you elaborate?