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 747397 - crash in _geocode_read_nominatim_attributes geocode-reverse.c:130
crash in _geocode_read_nominatim_attributes geocode-reverse.c:130
Status: RESOLVED FIXED
Product: geocode-glib
Classification: Other
Component: general
3.16.x
Other Linux
: Normal normal
: ---
Assigned To: geocode-glib maintainer(s)
geocode-glib maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-04-06 09:08 UTC by Yanko Kaneti
Modified: 2015-06-09 12:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
reverse: Check for NULL result in reverse_resolve() (934 bytes, patch)
2015-04-06 18:05 UTC, Jonas Danielsson
none Details | Review
reverse: Check for NULL from json_reader_list_members() (898 bytes, patch)
2015-04-06 18:05 UTC, Jonas Danielsson
none Details | Review
test-gcglib: Add test for unsuccessful reverse (1.47 KB, patch)
2015-04-12 19:07 UTC, Jonas Danielsson
none Details | Review
reverse: Check for NULL result in reverse_resolve() (934 bytes, patch)
2015-04-12 19:07 UTC, Jonas Danielsson
none Details | Review
reverse: Check for NULL from json_reader_list_members() (898 bytes, patch)
2015-04-12 19:07 UTC, Jonas Danielsson
none Details | Review
test-gcglib: Add test for unsuccessful reverse (1.54 KB, patch)
2015-04-13 19:05 UTC, Jonas Danielsson
none Details | Review
reverse: Check for NULL result in reverse_resolve() (941 bytes, patch)
2015-04-13 19:05 UTC, Jonas Danielsson
committed Details | Review
reverse: Check for NULL from json_reader_list_members() (963 bytes, patch)
2015-04-13 19:05 UTC, Jonas Danielsson
committed Details | Review
test-gcglib: Add test for unsuccessful reverse (1.56 KB, patch)
2015-04-13 19:08 UTC, Jonas Danielsson
committed Details | Review

Description Yanko Kaneti 2015-04-06 09:08:58 UTC
A crash here seems to have occurred regurarly for the last two fedora releases
https://retrace.fedoraproject.org/faf/problems/353259/

Now in the still cooking f22
https://bugzilla.redhat.com/show_bug.cgi?id=1209040
Comment 1 Jonas Danielsson 2015-04-06 14:06:00 UTC
Seems like we are missing a NULL check on the return from json_reader_list_members, will look into and fix when in front of a computer. Thanks for report!
Comment 2 Jonas Danielsson 2015-04-06 18:05:44 UTC
Created attachment 301032 [details] [review]
reverse: Check for NULL result in reverse_resolve()
Comment 3 Jonas Danielsson 2015-04-06 18:05:49 UTC
Created attachment 301033 [details] [review]
reverse: Check for NULL from json_reader_list_members()
Comment 4 Jonas Danielsson 2015-04-06 18:07:35 UTC
I was not able to reproduce the crash in the report. But these two patches fixes issues in the reverse code. The first one will make geocode_reverse_resolve abort if there is no result.

The second one checks for NULL return in the offending function from the report, so it might fix that issue. But I have no solid reproducer. Where exactly is the crash coming from? Would it be possible to contact someone who regularly sees it and could try the patch?
Comment 5 Jonas Danielsson 2015-04-06 18:10:26 UTC
Correction, the first one fixes an issue where geocode crashed if there was no results. :)
Comment 6 Bastien Nocera 2015-04-06 20:16:47 UTC
Both patches are missing regression tests.
Comment 7 Jonas Danielsson 2015-04-12 19:07:18 UTC
Created attachment 301421 [details] [review]
test-gcglib: Add test for unsuccessful reverse
Comment 8 Jonas Danielsson 2015-04-12 19:07:23 UTC
Created attachment 301422 [details] [review]
reverse: Check for NULL result in reverse_resolve()
Comment 9 Jonas Danielsson 2015-04-12 19:07:29 UTC
Created attachment 301423 [details] [review]
reverse: Check for NULL from json_reader_list_members()
Comment 10 Jonas Danielsson 2015-04-12 19:11:11 UTC
Well since I haven't been able to reproduce the crash from the bug report, I am not sure how to write a regression test for it. The patch in attachment 301423 [details] [review] fixes an issue on the line that the trace from the crash reported.

The seccond one fixes an issues shown by the new test_rev_fail-test in attachtment 301421.

Thanks!
Comment 11 Bastien Nocera 2015-04-13 08:48:38 UTC
Review of attachment 301423 [details] [review]:

::: geocode-glib/geocode-reverse.c
@@ +128,3 @@
 	members = json_reader_list_members (reader);
 
+	for (i = 0; members != NULL && members[i] != NULL; i++) {

Pretty sure that g_strfreev() doesn't like NULL being passed to it.

Best would to do check for NULL before, so:
if (members == NULL) {
  json_reader_end_member (reader);
  return;
}
Comment 12 Bastien Nocera 2015-04-13 08:49:51 UTC
Review of attachment 301421 [details] [review]:

::: geocode-glib/test-gcglib.c
@@ +152,3 @@
+
+	place = geocode_reverse_resolve (rev, &error);
+	g_assert (place == NULL);

Looks fine, though do you want to make a g_assert_error() call as well?
Comment 13 Bastien Nocera 2015-04-13 08:52:00 UTC
Review of attachment 301422 [details] [review]:

::: geocode-glib/geocode-reverse.c
@@ +515,3 @@
 
+	if (!result)
+		return NULL;

We don't propagate an error here?

Don't we need a similar check in the async version?
Comment 14 Jonas Danielsson 2015-04-13 19:03:23 UTC
Review of attachment 301423 [details] [review]:

::: geocode-glib/geocode-reverse.c
@@ +128,3 @@
 	members = json_reader_list_members (reader);
 
+	for (i = 0; members != NULL && members[i] != NULL; i++) {

Agreed.
Comment 15 Jonas Danielsson 2015-04-13 19:04:32 UTC
Review of attachment 301422 [details] [review]:

::: geocode-glib/geocode-reverse.c
@@ +515,3 @@
 
+	if (!result)
+		return NULL;

We do, we will get an error that is propagated from resolve_json, with the error message "Unable to geocode", the same you get from Nominatim web service if you supply lat/lon that does not give a result.

The async version already checks for NULL from resolve_json, it was missing in the sync one.
Comment 16 Jonas Danielsson 2015-04-13 19:04:51 UTC
Review of attachment 301421 [details] [review]:

::: geocode-glib/test-gcglib.c
@@ +152,3 @@
+
+	place = geocode_reverse_resolve (rev, &error);
+	g_assert (place == NULL);

Yes, will add.
Comment 17 Jonas Danielsson 2015-04-13 19:05:23 UTC
Created attachment 301484 [details] [review]
test-gcglib: Add test for unsuccessful reverse
Comment 18 Jonas Danielsson 2015-04-13 19:05:29 UTC
Created attachment 301485 [details] [review]
reverse: Check for NULL result in reverse_resolve()
Comment 19 Jonas Danielsson 2015-04-13 19:05:36 UTC
Created attachment 301486 [details] [review]
reverse: Check for NULL from json_reader_list_members()
Comment 20 Jonas Danielsson 2015-04-13 19:06:00 UTC
Thanks for review!
Comment 21 Jonas Danielsson 2015-04-13 19:08:46 UTC
Created attachment 301487 [details] [review]
test-gcglib: Add test for unsuccessful reverse
Comment 22 Bastien Nocera 2015-04-21 13:56:56 UTC
Review of attachment 301485 [details] [review]:

Looks good.
Comment 23 Bastien Nocera 2015-04-21 13:57:46 UTC
Review of attachment 301486 [details] [review]:

Looks good.
Comment 24 Bastien Nocera 2015-04-21 13:58:17 UTC
Review of attachment 301487 [details] [review]:

Looks good.
Comment 25 Jonas Danielsson 2015-04-22 20:34:15 UTC
Attachment 301485 [details] pushed as a7d4ffc - reverse: Check for NULL result in reverse_resolve()
Attachment 301486 [details] pushed as 8877b11 - reverse: Check for NULL from json_reader_list_members()
Attachment 301487 [details] pushed as 31729af - test-gcglib: Add test for unsuccessful reverse
Comment 26 Jonas Danielsson 2015-04-22 20:35:00 UTC
Should this go into 3.14?
Comment 27 Bastien Nocera 2015-06-09 12:15:00 UTC
(In reply to Jonas Danielsson from comment #26)
> Should this go into 3.14?

If it applies, definitely.