Closed Bug 2087770 Opened 15 days ago Closed 13 days ago

TEST-UNEXPECTED-FAIL | testing/enterprise/test_felt_browser_access_connector.py BrowserAccessConnector.test_browser_access_connector_default_on | AssertionError

Categories

(Core :: Preferences: Backend, defect)

defect

Tracking

()

RESOLVED FIXED
161 Branch
Tracking Status
firefox-esr153 --- unaffected
firefox159 --- unaffected
firefox160 --- unaffected
firefox161 --- fixed

People

(Reporter: gerard-majax, Assigned: gerard-majax)

References

(Blocks 2 open bugs, Regression)

Details

(Keywords: regression)

Attachments

(2 external files)

Since today's enterprise-main merge against upstream main merge, we discovered a regression on one of our tests.

According to Claude's analysis, this is related to pref snapshot handling, and the triggering point is related to the removal of the socket process:

Root cause

Once the parent process has built its shared pref snapshot, a pref from that snapshot can't be removed from it. Deleting it (deleteBranch, or clearUserPref on a pref that only has a user value) instead leaves an empty placeholder of type None in the parent's pref table, so the old snapshot value stays hidden.

Setting a default on that pref again finds the placeholder. Pref::SetDefaultValue then requires the stored type to match the new one exactly, and None never matches, so it returns NS_ERROR_UNEXPECTED. Setting a user value doesn't have this problem, because Pref::SetUserValue already adopts the new type.

The AccessConnector test hits exactly this:
1. The policy is applied at startup, before any child process exists. It sets a default for browser.ipProtection.mode, which has no default in any prefs file.
2. The first child process launches and the snapshot is built, now including mode = 3.
3. Disabling the policy makes PoliciesHelpers.restorePreferenceState() call deleteBranch, because there was no original default to restore. The pref becomes a placeholder.
4. Re-enabling calls setIntPref on the default branch, which fails.

Why it went undetected

All of these have to be true at once, and until this merge they almost never were:

- The pref must be in the snapshot. The snapshot is built when the first child process launches. Until bug 2077172, the socket process launched very early at startup, so the snapshot held little beyond the prefs files. Prefs set later stayed in the ordinary table, and deleting them really removed them. With the socket process gone, the first child launches later, after the console policies have run, so policy-set prefs end up in the snapshot.
- The pref must have no default in the prefs files. Otherwise restorePreferenceState writes the original default back and never calls deleteBranch.
- The default must be set again in the same session. Few things set defaults at runtime: mainly enterprise policies and Nimbus. Removing and re-adding a policy in one session is rare, and the upstream policy tests don't do it.
- The failure is quiet. pref_SetPref only prints a debug-build warning, "Rejected attempt to change type of pref … from none to int". In JS the policy engine catches the exception and logs it. All you notice is a pref that's missing.

That's also why only default_on fails: it's the only test where the policy is on before the first child launches and is then removed and re-added. default_off starts with the pref unset, so it's never in the snapshot.

STR:

Expected:
Test passes

Actual:
Test fails on asserting value of a pref

Component: Networking → Preferences: Backend

Looking at the code, I am a bit doubtful of that analysis, and I'd rather suspect a bug around PoliciesHelpers

Bug may have been introduced by bug 1960948, only revealed by the change of behavior recently in bug 2077172

Regressed by: 1960948

:leggert, since you are the author of the regressor, bug 2077172, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(leggert)

Could someone point me at the CI artifacts of the failure? The AI analysis and the indicated bugs seem somewhat unbelievable.

Flags: needinfo?(leggert)

(In reply to Lars Eggert [:lars] from comment #6)

Could someone point me at the CI artifacts of the failure? The AI analysis and the indicated bugs seem somewhat unbelievable.

yes, I'm far from being convinced myself ...

(In reply to Lars Eggert [:lars] from comment #6)

Could someone point me at the CI artifacts of the failure? The AI analysis and the indicated bugs seem somewhat unbelievable.

test failures are at https://treeherder.mozilla.org/jobs?repo=enterprise-firefox-try&revision=9ce8f0099dd663ff565efa592fb55cc1b000b856&searchStr=marionette-enterprise,

if you try to repro locally, there's https://github.com/mozilla/enterprise-firefox/commit/6d119e0bc4769f0a3e8c00a93e010f4b52f9ad8e to revert, which I landed as a workaround but may in fact be the correct fix, because I'm doubtful of the analysis provided earlier

You should be able to get builds from https://treeherder.mozilla.org/jobs?repo=enterprise-firefox-try&revision=9ce8f0099dd663ff565efa592fb55cc1b000b856&searchStr=enterprise%2Cbuild (make sure not to pick thunderbird)

Flags: needinfo?(leggert)

I think your diagnosis that the socket process removal exposed an existing libpref bug is correct, and your test/fix look basically OK. Some review comments from when I had Claude look into it here:

Review of the libpref fix (dad78e68be41) and its test (930bfc4095a6). These come from reading the code; I have not confirmed them with tests yet.

Correctness

  1. Locked placeholder. The new IsTypeNone() branch sets the type before the IsLocked() check. Pref::FromWrapper copies the locked/sanitized/sticky flags from the shared map, and ClearBranch and ClearUser only reset the type. So: lock a pref, launch a child, deleteBranch it, setIntPref on the default branch. That returns NS_OK and leaves a pref of type Int with no value: getPrefType says PREF_INT, getIntPref throws. Before the patch the call returned NS_ERROR_UNEXPECTED.
  2. Type change on static prefs. A deleted static pref is always in the shared map, so it can now be re-added with a different type than its C++ mirror. UpdateMirror then asserts in debug builds and keeps a stale mirror in release builds. I haven't checked whether deleting a static pref already reaches that assert without the patch.
  3. Stale stickiness. The placeholder keeps mIsSticky, and SetDefaultValue only ever sets it, never clears it. A default re-added without stickiness still behaves as sticky.
  4. Comment too narrow. The new comment says a typeless entry always shadows a deleted shared pref. ClearBranch and ClearUser also leave typeless entries for sanitized prefs that are not in the shared map, so their behaviour changes too.

Test

  1. No child-side check. The test checks only the parent. The content process has its own typeless mask entry (SetPreference); a sendCommand reading the pref in the child would check that it sees the re-added default.
  2. Edge cases not covered. Nothing tests re-adding with a different type, or the locked and sticky cases above.
  3. No cleanup. The pref set by the test is never removed.

Design

  1. Duplicate type setting. pref_SetPref already sets the type on a newly created entry; the new branch duplicates that for the default case.
  2. Fix it where the placeholder is made. Only the type is reset when the placeholder is created; the other flags survive. Resetting the entry to a clean state at the three SetType(PrefType::None) sites (ClearBranch, ClearUser, content SetPreference) would address 1 and 3 together.

1, 3 and 9 seem the most important to me; 5 is cheap to add.

Flags: needinfo?(leggert)
Severity: -- → S3
Assignee: nobody → lissyx+mozillians
Status: NEW → ASSIGNED

Deleting a pref that is in the shared pref map leaves a typeless entry
in the parent to mask it, which SetDefaultValue() rejected for any type.

Status: ASSIGNED → RESOLVED
Closed: 13 days ago
Resolution: --- → FIXED
Target Milestone: --- → 161 Branch
Blocks: 2091279
QA Whiteboard: [qa-triage-done-c162/b161]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: