Closed Bug 1041037 Opened 10 years ago Closed 3 years ago

ContactService concurrency issues

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: rnewman, Assigned: stully)

References

Details

ContactService declares two members:

    private String mAccountName;
    private String mAccountType;

It then freely accesses these from within cursor processor code and runnables from various threads:

Background:

    private void gotDeviceAccount(final Runnable handleMessage) {
        // Force the handleMessage runnable and getDefaultGroupId to run on the background thread
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                getDefaultGroupId();

                // Don't log a user's account if not debug mode. Otherwise, just log a message
                // saying that we got an account to use
                if (mAccountName == null) {


UI thread:

        final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
        builder.setTitle(mActivity.getResources().getString(R.string.contacts_account_chooser_dialog_title))
            .setSingleChoiceItems(accountNames, 0, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int position) {
                    // Set the account name and type when an item is selected and dismiss the dialog
                    mAccountName = accounts[position].name;
                    mAccountType = accounts[position].type;
                    dialog.dismiss();
                    gotDeviceAccount(handleMessage);
                }
            });

        mActivity.runOnUiThread(new Runnable() {
            public void run() {
                builder.show();
            }


And who knows what else for the 8 other methods that have their way with these members.

These are fundamental concurrency errors. There might be others in this file. I suggest a thorough concurrency audit, beyond simply fixing this bug.
May need to be closed when bug 1193431 is fixed.
See Also: → 1193431
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.