Skip to content

Fix security exception crash while accessing network location provider #1498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2018

Conversation

maskaravivek
Copy link
Member

Description

Fixes #1480

The app was not asking for permissions before subscribing to location updates from the network provider. This was leading to a security exception.

Tests performed

Unable to reproduce the crash using the steps mentioned in the issue.

@neslihanturan @misaochan Can you guys help in testing if its reproducible on your end.

@codecov-io
Copy link

codecov-io commented May 6, 2018

Codecov Report

Merging #1498 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1498      +/-   ##
=========================================
- Coverage    3.21%    3.2%   -0.02%     
=========================================
  Files         132     132              
  Lines        7091    7116      +25     
  Branches      682     684       +2     
=========================================
  Hits          228     228              
- Misses       6848    6873      +25     
  Partials       15      15
Impacted Files Coverage Δ
...e/nrw/commons/location/LocationServiceManager.java 0% <0%> (ø) ⬆️
...ava/fr/free/nrw/commons/nearby/NearbyActivity.java 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 228aa21...8b8ef0c. Read the comment docs.

@neslihanturan
Copy link
Collaborator

neslihanturan commented May 7, 2018

@maskaravivek I dont get security exception with steps now. But still I do get crash with meaningless logs:/

05-07 11:27:07.439 4640-4691/fr.free.nrw.commons.debug E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa249f920 05-07 11:27:07.842 4640-4728/fr.free.nrw.commons.debug A/libc: /usr/local/google/buildbot/src/android/ndk-r15-release/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type mapbox::sqlite::Exception: attempt to write a readonly database" failed 05-07 11:27:07.843 4640-4728/fr.free.nrw.commons.debug A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 4728 (DefaultFileSour)

@maskaravivek
Copy link
Member Author

@neslihanturan Is this happening consistently on a real test phone? Or did you test on an emulator?

@albendz
Copy link
Contributor

albendz commented May 11, 2018

Testing on a Samsung physical device with Android 7.0, API 24. Consistently crashes prior to changes and consistently crashes after changes. Have not been able to confirm stacktraces are the same since Android Studio keeps cleaning them up (let me know of a way to save them if further testing is needed).

Just to clarify repro: Open app, go to nearby, log out, log in, go to nearby -> crash

@maskaravivek
Copy link
Member Author

@albendz Logs would be quite helpful to debug further. Can you please try using pidcat for logs.

https://github.com/JakeWharton/pidcat

@maskaravivek
Copy link
Member Author

@albendz Are you sure that this PR doesn't fix the issue for you. I tried reproducing it and was able to successfully reproduce it without the fix. After this fix, the error was no longer occurring for me.

@albendz
Copy link
Contributor

albendz commented May 12, 2018

I'll retest and hopefully get back to you soon.

@misaochan
Copy link
Member

Sorry for the slow response @maskaravivek - I will try to help test as well, today or tomorrow.

@albendz
Copy link
Contributor

albendz commented May 13, 2018

Yes, I'm sure. Though, I still can't confirm the error I'm seeing is the same as what you fixed. I don't see an exception, only "05-13 20:49:25.156 18785-18890/fr.free.nrw.commons.debug A/libc: /usr/local/google/buildbot/src/android/ndk-r15-release/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type mapbox::sqlite::Exception: attempt to write a readonly database" failed
Fatal signal 6 (SIGABRT), code -6 in tid 18890 (DefaultFileSour)" both with and without your changes. I confirmed that when stepping through your code with a debugger, you changes were hit. This may be a separate issue I am hitting.

@maskaravivek
Copy link
Member Author

Thanks for helping in testing @albendz.

The error that you are facing seems to be different than what I have fixed in the PR. The important logline seems to be:

Fatal signal 6 (SIGABRT), code -6 in tid 18890 (DefaultFileSour)

And the possible reasons could be:

In any case, IMO this PR can be merged as it fixes an issue where location permissions were not being checked before registering for location updates.

@misaochan
Copy link
Member

I am experiencing the same issue when following the steps at #1480 - logs below. However, I am OK with merging this PR since it fixes a different issue, but not closing #1480 . @neslihanturan , what do you think?

05-14 20:57:14.763 7270-7316/fr.free.nrw.commons.debug A/libc: /usr/local/google/buildbot/src/android/ndk-r15-release/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type mapbox::sqlite::Exception: attempt to write a readonly database" failed
05-14 20:57:14.784 7270-7316/fr.free.nrw.commons.debug A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 7316 (DefaultFileSour)
05-14 20:57:14.848 7443-7443/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'google/sdk_google_phone_x86/generic_x86:7.1.1/NYC/4498512:userdebug/test-keys'
    Revision: '0'
    ABI: 'x86'
    pid: 7270, tid: 7316, name: DefaultFileSour  >>> fr.free.nrw.commons.debug <<<
    signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
    Abort message: '/usr/local/google/buildbot/src/android/ndk-r15-release/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type mapbox::sqlite::Exception: attempt to write a readonly database" failed'
        eax 00000000  ebx 00001c66  ecx 00001c94  edx 00000006
        esi 90585978  edi 90585920
        xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b
        eip b0225424  ebp 90584c48  esp 90584bec  flags 00000296
05-14 20:57:14.850 7443-7443/? A/DEBUG: backtrace:
        #00 pc ffffe424  [vdso:b0225000] (__kernel_vsyscall+16)
        #01 pc 0007a03c  /system/lib/libc.so (tgkill+28)
        #02 pc 00075885  /system/lib/libc.so (pthread_kill+85)
        #03 pc 0002785a  /system/lib/libc.so (raise+42)
        #04 pc 0001ee36  /system/lib/libc.so (abort+86)
        #05 pc 00023d48  /system/lib/libc.so (__libc_fatal+40)
        #06 pc 0001f300  /system/lib/libc.so (__assert2+64)
        #07 pc 0049cff4  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #08 pc 0049d107  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #09 pc 0049a379  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #10 pc 00499afc  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #11 pc 0014cb5f  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #12 pc 0013d6fc  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #13 pc 0013d5b7  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #14 pc 0013d48a  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #15 pc 00127c32  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #16 pc 0012f65a  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #17 pc 0012f4f0  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #18 pc 00273a3c  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #19 pc 00273b93  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #20 pc 0012e4b2  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #21 pc 0012e3e7  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
05-14 20:57:14.851 7443-7443/? A/DEBUG:     #22 pc 00350cb9  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #23 pc 00350bc5  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #24 pc 0012c4bb  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #25 pc 0012c32a  /data/app/fr.free.nrw.commons.debug-1/lib/x86/libmapbox-gl.so
        #26 pc 00074fe2  /system/lib/libc.so (_ZL15__pthread_startPv+210)
        #27 pc 0002029e  /system/lib/libc.so (__start_thread+30)
        #28 pc 0001e076  /system/lib/libc.so (__bionic_clone+70)
05-14 20:57:15.527 1665-7448/system_process W/ActivityManager:   Force finishing activity fr.free.nrw.commons.debug/fr.free.nrw.commons.nearby.NearbyActivity

and

05-14 20:57:15.635 7451-7451/? W/System.err: java.io.FileNotFoundException: /jacoco.exec (Read-only file system)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
        at org.jacoco.agent.rt.internal_773e439.output.FileOutput.openFile(FileOutput.java:67)
        at org.jacoco.agent.rt.internal_773e439.output.FileOutput.startup(FileOutput.java:49)
        at org.jacoco.agent.rt.internal_773e439.Agent.startup(Agent.java:122)
        at org.jacoco.agent.rt.internal_773e439.Agent.getInstance(Agent.java:50)
        at org.jacoco.agent.rt.internal_773e439.Offline.<clinit>(Offline.java:31)
        at org.jacoco.agent.rt.internal_773e439.Offline.getProbes(Offline.java:51)
        at fr.free.nrw.commons.CommonsApplication.$jacocoInit(CommonsApplication.java)
        at fr.free.nrw.commons.CommonsApplication.<init>(CommonsApplication.java)
        at java.lang.Class.newInstance(Native Method)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1007)
        at android.app.Instrumentation.newApplication(Instrumentation.java:992)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
        at android.app.ActivityThread.-wrap2(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
        at android.os.Handler.dispatchMessage(Handler.java:102)

@albendz
Copy link
Contributor

albendz commented May 14, 2018

Based on what Vivek sent, the SIGABRT 6 issue is related to something else. If you're seeing that, it's not the issue. Since that seems to be caused by overloading the UI thread, we might be doing the repro too quickly...

@misaochan
Copy link
Member

I waited for over 10 seconds after logging in before I loaded Nearby, to be sure that speed wasn't the issue. :) However, I personally think it would be best to focus on fixing the jacoco.exec error instead of SIGABRT, as the latter is much more general and can potentially be caused by library errors. After we fix jacoco, we can see if the crash still occurs.

@neslihanturan
Copy link
Collaborator

@misaochan I agree with you. My tests gave same results so we should leave #1480 open but also merge this PR

@misaochan misaochan merged commit d891b8f into commons-app:master May 15, 2018
maskaravivek pushed a commit that referenced this pull request May 18, 2018
#1498)

* Fix security exception crash while accessing network location provider

* Added java docs
misaochan pushed a commit that referenced this pull request May 31, 2018
…rby (#1495)

* Localisation updates from https://translatewiki.net.

* Integrate API for displaying featured images (#1456)

* Integrate API for displaying featured images

* Add pagination and refactor code so that it can be reused for category images

* Add license info to the images

* Fix author view

* Remove unused values

* Fix minor issues with featured images

* Fix null license url issue

* Remove some log lines

* Fix back navigation issue

* fix tests

* fix test inits

* Gracefully handling various error situations

* Added java docs

* Update pull_request_template.md (#1476)

* Update pull_request_template.md

* Remove Javadocs mention

* Added required/optional notes

* resolves #1464 : MediaDataExtractor is making inefficient (redundant) server calls (#1496)

* Open map of place where picture was taken (#1360)

* Intent to map added

*  Merge conflicts resolved

*  Added the functionality to hide FAB incase of null coordinate

*  Merge Conflict resolved

*  Improve pr quality

* Improve Quality

*  Added nested FAB animations

* Nested FAB implemented

*  Improve Quality

*  Added up arrow

*  Javadocs Added

* Add nearby tutorial (#1467)

* Add dependency for MaterialShowcase

* Add actionview class to get a reference to material showcase

* Create a NearbyMaterialShowcaseSequence class

* Apply sequence steps

* Add first three steps of nearby showcase

* Add sequence id constants to make sure they will be displayed only once

* Add last step of sequence to explain plus fab

* Create an object to prevent customize all sequences every time

* Fix typo

* Code cleanup

* Add strings to strings.xml

* Code cleanup

* Revert irrelevant change

* Revert irrelevant change

* Remove showcaseview for recenter button

* Use single showcaseView instead of sequence

* Add single showcase view insted of sequence to be able to edit text style

* Make sure it will be displayed only once

* Cleanup

* Update strings

* Change dismiss text style

* CONTRIBUTING: fix formatting of the gist of the guidelines (#1453)

* CONTRIBUTING: fix formatting of the gist of the guidelines

First level headings for a gist seems to be overkill.

So, replace first level headings with an ordered-list which
sounds more meaningful.

* CONTRIBUTING: specify clearly that 'blame' is a feature of "Git"

The contributing file specifies about the ability to know who wrote
something without the need of @author javadoc tags but incorrectly
attributes the feature to GitHub.

Correctly attribute the feature to where it belongs, Git, and specify
the name of the feature to help users easily take advantage of it.

* Feature/switch to butterknife (#1494)

* Implemented butterknife in MediaDetailFragment [issue #1491]

* Implemented butterknife in MediaDetailPagerFragment [[issue #1491]]

* post merge upstream master wip [[issue #1491]]

* Localisation updates from https://translatewiki.net.

* Bug fix #1504 (#1506)

* Bug fix #1504

* Filtered messages with ConnectException [issue #1504]

* A generalised message for exceptions in Nearby Activity [issue #1504]

* Localisation updates from https://translatewiki.net.

* Fix security exception crash while accessing network location provider (#1498)

* Fix security exception crash while accessing network location provider

* Added java docs

* Localisation updates from https://translatewiki.net.

* Log P18 edits to wikidata corresponding wikidata entity on uploading a nearby image

* Added java docs

* Fix test build

* Refresh nearby

* Refresh nearby list on successful edit

* Java docs

* Make authenticated wikidata edits

* Updated toast message to show entity name that was edited
@maskaravivek maskaravivek deleted the locationManager branch September 12, 2018 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants