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 764814 - Crashes fetching lyrics with '%' in them
Crashes fetching lyrics with '%' in them
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: lua
git master
Other Linux
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
: 764291 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-04-09 11:50 UTC by Bastien Nocera
Modified: 2016-10-22 12:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
metrolyrics: encode artist/title for correct url (1.04 KB, patch)
2016-04-09 13:29 UTC, Victor Toso
committed Details | Review
tests: metrolyrics with encoded url (1.78 KB, patch)
2016-04-09 13:29 UTC, Victor Toso
none Details | Review
lua-factory: fix crash on error (1.93 KB, patch)
2016-04-28 20:56 UTC, Victor Toso
committed Details | Review
tests: metrolyrics with encoded url (1.78 KB, patch)
2016-04-28 21:32 UTC, Victor Toso
none Details | Review
metrolyrics: char '%' is invalid in metrolyrics url (999 bytes, patch)
2016-04-29 09:24 UTC, Victor Toso
committed Details | Review
tests: metrolyrics with encoded url (1.84 KB, patch)
2016-04-29 09:24 UTC, Victor Toso
none Details | Review
tests: metrolyrics with bad url (1.67 KB, patch)
2016-04-29 09:25 UTC, Victor Toso
none Details | Review
tests: metrolyrics with encoded url (1.91 KB, patch)
2016-04-29 12:29 UTC, Victor Toso
committed Details | Review
tests: metrolyrics with nonexistent lyrics (1.82 KB, patch)
2016-04-29 12:29 UTC, Victor Toso
committed Details | Review

Description Bastien Nocera 2016-04-09 11:50:06 UTC
2 bugs, first, metrolyrics should do some encoding...

The title of the media is '99% Invisible'

(grilo-test-ui-0.3:28993): Grilo-WARNING **: [lua-library] grl-lua-library.c:496: Can't fetch element 1 (URL: http://www.metrolyrics.com/99%-Invisible-lyrics-Roman-Mars.html): 'Invalid request URI or header: Bad Request'
(grilo-test-ui-0.3:28993): Grilo-WARNING **: [lua-library] grl-lua-library.c:1280: This Lyrics do not match our parser! Please file a bug!

And crash:
  • #0 vfprintf
    from /lib64/libc.so.6
  • #1 vasprintf
    from /lib64/libc.so.6
  • #2 g_vasprintf
    at gprintf.c line 316
  • #3 g_strdup_vprintf
    at gstrfuncs.c line 514
  • #4 grl_log_valist
    at grl-log.c line 298
  • #5 grl_log
    at grl-log.c line 329
  • #6 grl_util_fetch_done
    at grl-lua-library.c line 532
  • #7 g_simple_async_result_complete
    at gsimpleasyncresult.c line 801
  • #8 read_async_cb
    at grl-net-wc.c line 623
  • #9 async_ready_callback_wrapper
    at ginputstream.c line 532
  • #10 g_task_return_now
    at gtask.c line 1107
  • #11 complete_in_idle_cb
    at gtask.c line 1121
  • #12 g_idle_dispatch
    at gmain.c line 5454
  • #13 g_main_dispatch
    at gmain.c line 3157
  • #14 g_main_context_dispatch
    at gmain.c line 3782
  • #15 g_main_context_iterate
    at gmain.c line 3853
  • #16 g_main_loop_run
    at gmain.c line 4047
  • #17 gtk_main
    at gtkmain.c line 1266
  • #18 main
    at main.c line 2397

Comment 1 Bastien Nocera 2016-04-09 11:51:52 UTC
Looks like it crashes whenever there's an error. Still, the "Bad request" should be avoided.
Comment 2 Victor Toso 2016-04-09 13:29:28 UTC
Created attachment 325631 [details] [review]
metrolyrics: encode artist/title for correct url
Comment 3 Victor Toso 2016-04-09 13:29:40 UTC
Created attachment 325632 [details] [review]
tests: metrolyrics with encoded url
Comment 4 Victor Toso 2016-04-09 13:30:43 UTC
(In reply to Bastien Nocera from comment #1)
> Looks like it crashes whenever there's an error.

I'll get back to this later on!
Comment 5 Victor Toso 2016-04-27 11:01:23 UTC
(In reply to Bastien Nocera from comment #1)
> Looks like it crashes whenever there's an error. Still, the "Bad request"
> should be avoided.

Finally got some time to look into it, this is probably the same as bug 764291. For some reason GRL_WARNING is aborting (changing the warnings to debug avoids the crash).

I'll looking into why this started to happen...
Comment 6 Bastien Nocera 2016-04-27 11:05:05 UTC
Pretty sure this isn't GRL_WARNING() causing the crash, we don't even see what it's supposed to print ("calling source callback function fail: %s"...)
Comment 7 Victor Toso 2016-04-28 20:51:19 UTC
(In reply to Bastien Nocera from comment #6)
> Pretty sure this isn't GRL_WARNING() causing the crash, we don't even see
> what it's supposed to print ("calling source callback function fail: %s"...)

Sorry, In my tiny 'reproducer' I had g_test_init() set... oh well :)

The problem that I can see happening here is that we are calling grl_lua_operations_pcall witha non null GError*.

Let me know if the patch that I'll attach shortly fixes your crash as well.
Comment 8 Victor Toso 2016-04-28 20:56:04 UTC
Created attachment 326968 [details] [review]
lua-factory: fix crash on error

On grl_net_wc_request_async callback, we could be using the GError
pointer more then once in the function, which leads to non null value.

This patch clears the GError pointer and add guards to
grl_lua_operations_pcall.
Comment 9 Bastien Nocera 2016-04-28 21:22:56 UTC
Review of attachment 325631 [details] [review]:

Sure.
Comment 10 Bastien Nocera 2016-04-28 21:25:29 UTC
Review of attachment 325632 [details] [review]:

::: tests/lua-factory/sources/test_lua_metrolyrics.c
@@ +94,3 @@
 
+    lyrics = get_lyrics (source, audios[i].artist, audios[i].title);
+    g_assert_nonnull (lyrics);

Why would it not fail for the example you added? It would fail indeed. You might want to move the assertion below the == NULL check.
Comment 11 Bastien Nocera 2016-04-28 21:26:28 UTC
Review of attachment 326968 [details] [review]:

Sure.
Comment 12 Victor Toso 2016-04-28 21:32:59 UTC
Created attachment 326971 [details] [review]
tests: metrolyrics with encoded url
Comment 13 Bastien Nocera 2016-04-28 21:39:05 UTC
Review of attachment 326971 [details] [review]:

Looks good!
Comment 14 Victor Toso 2016-04-28 22:25:52 UTC
Review of attachment 326971 [details] [review]:

Sorry, I did not test this properly after the crash fix.
This patch breaks the tests as the fetch fails [0]. I'll be fixing this soon.

[0] Grilo-WARNING **: [lua-library] grl-lua-library.c:496: Can't fetch element 1 (URL: http://www.metrolyrics.com/99%25-Invisible-lyrics-Roman-Mars.html): 'Invalid request URI or header: Bad Request'
Comment 15 Victor Toso 2016-04-29 09:24:49 UTC
Created attachment 326997 [details] [review]
metrolyrics: char '%' is invalid in metrolyrics url

We should not include '%' or its encoded version to metrolyrics
requests.
Comment 16 Victor Toso 2016-04-29 09:24:58 UTC
Created attachment 326998 [details] [review]
tests: metrolyrics with encoded url
Comment 17 Victor Toso 2016-04-29 09:25:06 UTC
Created attachment 326999 [details] [review]
tests: metrolyrics with bad url
Comment 18 Bastien Nocera 2016-04-29 10:40:05 UTC
Review of attachment 326997 [details] [review]:

Sure.
Comment 19 Bastien Nocera 2016-04-29 10:41:35 UTC
Review of attachment 326998 [details] [review]:

A little more text would help:
"Check that we don't create invalid requests for the metrolyrics server"
Comment 20 Bastien Nocera 2016-04-29 10:42:41 UTC
Review of attachment 326999 [details] [review]:

Is that a 404? or something else? It's not clear.
Comment 21 Victor Toso 2016-04-29 12:18:40 UTC
(In reply to Bastien Nocera from comment #20)
> Review of attachment 326999 [details] [review] [review]:
> 
> Is that a 404? or something else? It's not clear.

Yes, It is a valid url but we get 404 from server due missing lyrics.
I'll update the patch and send it again. Thanks for the reviews.
Comment 22 Victor Toso 2016-04-29 12:29:21 UTC
Created attachment 327015 [details] [review]
tests: metrolyrics with encoded url

Check that we don't create invalid requests for the metrolyrics server
Comment 23 Victor Toso 2016-04-29 12:29:32 UTC
Created attachment 327016 [details] [review]
tests: metrolyrics with nonexistent lyrics

Testing metrolyrics under bad requests or nonexistent lyrics. The
expected reply from the server is the 404 'Not Found' response.
Comment 24 Victor Toso 2016-04-29 12:31:41 UTC
Attachment 325631 [details] pushed as 54b43dd - metrolyrics: encode artist/title for correct url
Attachment 326968 [details] pushed as c30ada5 - lua-factory: fix crash on error
Attachment 326997 [details] pushed as e80c26e - metrolyrics: char '%' is invalid in metrolyrics url
Comment 25 Bastien Nocera 2016-04-29 12:33:11 UTC
Review of attachment 327015 [details] [review]:

Yep.
Comment 26 Bastien Nocera 2016-04-29 12:33:35 UTC
Review of attachment 327016 [details] [review]:

Good.
Comment 27 Victor Toso 2016-04-29 12:41:35 UTC
Attachment 327015 [details] pushed as 7069733 - tests: metrolyrics with encoded url
Attachment 327016 [details] pushed as b5b1b4b - tests: metrolyrics with nonexistent lyrics
Comment 28 Victor Toso 2016-10-22 12:25:30 UTC
*** Bug 764291 has been marked as a duplicate of this bug. ***