Closed Bug 1596025 Opened 3 months ago Closed 3 months ago

WebIDL aliases induce non-determinism

Categories

(Core :: DOM: Bindings (WebIDL), defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: glandium, Assigned: glandium)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

This makes absolutely no sense, but I swear I've had it happen on my machine, although I can reproduce anymore. And it happened on automation (which is what got me to look on my machine in the first place).

This manifests itself when trying to replicate Firefox build, and the relevant difference in libxul.so is the following:

│ │ ├── readelf --wide --decompress --hex-dump=.rodata {}
│ │ │ @@ -170992,17 +170992,17 @@
│ │ │    0x05c53ed0 6576756e 69717565 00494442 43757273 evunique.IDBCurs
│ │ │    0x05c53ee0 6f725769 74685661 6c756500 2773746f orWithValue.'sto
│ │ │    0x05c53ef0 72616765 27206d65 6d626572 206f6620 rage' member of 
│ │ │    0x05c53f00 4944424f 70656e44 424f7074 696f6e73 IDBOpenDBOptions
│ │ │    0x05c53f10 00494442 46696c65 48616e64 6c650049 .IDBFileHandle.I
│ │ │    0x05c53f20 44424669 6c655265 71756573 74006d75 DBFileRequest.mu
│ │ │    0x05c53f30 6c746945 6e747279 00494442 496e6465 ltiEntry.IDBInde
│ │ │ -  0x05c53f40 78006d6f 7a476574 416c6c00 67657441 x.mozGetAll.getA
│ │ │ -  0x05c53f50 6c6c4b65 7973006d 6f7a4765 74416c6c llKeys.mozGetAll
│ │ │ -  0x05c53f60 4b657973 00494442 4b657952 616e6765 Keys.IDBKeyRange
│ │ │ +  0x05c53f40 78006765 74416c6c 4b657973 006d6f7a x.getAllKeys.moz
│ │ │ +  0x05c53f50 47657441 6c6c4b65 7973006d 6f7a4765 GetAllKeys.mozGe
│ │ │ +  0x05c53f60 74416c6c 00494442 4b657952 616e6765 tAll.IDBKeyRange
│ │ │    0x05c53f70 00494442 4c6f6361 6c654177 6172654b .IDBLocaleAwareK
│ │ │    0x05c53f80 65795261 6e676500 4944424d 75746162 eyRange.IDBMutab
│ │ │    0x05c53f90 6c654669 6c65006b 65795061 74680061 leFile.keyPath.a
│ │ │    0x05c53fa0 75746f49 6e637265 6d656e74 00276b65 utoIncrement.'ke
│ │ │    0x05c53fb0 79506174 6827206d 656d6265 72206f66 yPath' member of
│ │ │    0x05c53fc0 20494442 4f626a65 63745374 6f726550  IDBObjectStoreP
│ │ │    0x05c53fd0 6172616d 65746572 73004944 424f626a arameters.IDBObj

(from https://firefoxci.taskcluster-artifacts.net/Cytt_3WHRj6I1LrKlsd2KQ/0/public/diff.html)

This, in turn, can be rooted in the following difference in the generated files:

│ ├── dom/bindings/IDBIndexBinding.cpp
│ │┄ ordering differences only
│ │ @@ -1151,36 +1151,36 @@
│ │        *interfaceCache = nullptr;
│ │      }
│ │      return;
│ │    }
│ │  
│ │    JS::Rooted<JS::Value> aliasedVal(aCx);
│ │  
│ │ -  if (!JS_GetProperty(aCx, proto, "getAll", &aliasedVal)) {
│ │ +  if (!JS_GetProperty(aCx, proto, "getAllKeys", &aliasedVal)) {
│ │      *protoCache = nullptr;
│ │      if (interfaceCache) {
│ │        *interfaceCache = nullptr;
│ │      }
│ │      return;
│ │    }
│ │ -  if (!JS_DefineProperty(aCx, proto, "mozGetAll", aliasedVal, JSPROP_ENUMERATE)) {
│ │ +  if (!JS_DefineProperty(aCx, proto, "mozGetAllKeys", aliasedVal, JSPROP_ENUMERATE)) {
│ │      *protoCache = nullptr;
│ │      if (interfaceCache) {
│ │        *interfaceCache = nullptr;
│ │      }
│ │      return;
│ │    }
│ │ -  if (!JS_GetProperty(aCx, proto, "getAllKeys", &aliasedVal)) {
│ │ +  if (!JS_GetProperty(aCx, proto, "getAll", &aliasedVal)) {
│ │      *protoCache = nullptr;
│ │      if (interfaceCache) {
│ │        *interfaceCache = nullptr;
│ │      }
│ │      return;
│ │    }
│ │ -  if (!JS_DefineProperty(aCx, proto, "mozGetAllKeys", aliasedVal, JSPROP_ENUMERATE)) {
│ │ +  if (!JS_DefineProperty(aCx, proto, "mozGetAll", aliasedVal, JSPROP_ENUMERATE)) {
│ │      *protoCache = nullptr;
│ │      if (interfaceCache) {
│ │        *interfaceCache = nullptr;
│ │      }
│ │      return;
│ │    }
│ │  }

(from a comparison between https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/dPEoteABSD63V7R6CvqwvQ/runs/0/artifacts/public/build/target.generated-files.tar.gz and https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/AuXosduJT8iC6502OwhtYQ/runs/0/artifacts/public/build/target.generated-files.tar.gz)

What makes absolute no sense is that what generates this code is, AFAICT:
https://hg.mozilla.org/try/file/aa4f685faecec8006b6090ac346749038d30d703/dom/bindings/Codegen.py#l3229
and
https://hg.mozilla.org/try/file/aa4f685faecec8006b6090ac346749038d30d703/dom/bindings/Codegen.py#l3216
... and they're using sorted lists.

I figured out what's wrong. sorted(aliasedMembers) looks like it is sorting by __repr__, which contains the address of the object, like <WebIDL.IDLMethod object at 0x7f83be5d8b50>.

Assignee: nobody → mh+mozilla
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/a01e42ada2cd
Fix non-determinism with WebIDL aliases. r=bzbarsky
Priority: -- → P1
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
You need to log in before you can comment on or make changes to this bug.