New issue
Advanced search Search tips

Issue 919553 link

Starred by 1 user

Issue metadata

Status: Unconfirmed
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

blink-gc: "class Foo contains a GC root in field bar" message can be unclear

Project Member Reported by mlamouri@chromium.org, Jan 7

Issue description

I was adding a test class that looked like:
```
class WaitForEvent : public NativeEventListener {
 [...]

 private:
  Persistent<Element> element_;
};
```

I got the following errors:
```
-m64 /Brepro /W4 -Wimplicit-fallthrough -Wthread-safety /WX /wd4091 /wd4127 /wd4251 /wd4275 /wd4312 /wd4324 /wd4351 /wd4355 /wd4503 /wd4589 /wd4611 /wd4100 /wd4121 /wd4244 /wd4505 /wd4510 /wd4512 /wd4610 /wd4838 /wd4995 /wd4996 /wd4456 /wd4457 /wd4458 /wd4459 /wd4200 /wd4201 /wd4204 /wd4221 /wd4245 /wd4267 /wd4305 /wd4389 /wd4702 /wd4701 /wd4703 /wd4661 /wd4706 /wd4715 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-ignored-pragma-optimize /Od /Ob0 /GF /MDd -Xclang -add-plugin -Xclang find-bad-constructs -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare /wd4305 /wd4324 /wd4714 /wd4800 /wd4996 -Xclang -add-plugin -Xclang blink-gc-plugin -Wno-inconsistent-missing-override /wd4800 -Wno-shorten-64-to-32 /wd4344 /wd4706 /wd4291 -Wno-inconsistent-missing-override -DLIBXML_STATIC= -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare /TP /wd4577 /GR- /c ../../third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_controller_test.cc /Foobj/third_party/blink/renderer/modules/unit_tests/picture_in_picture_controller_test.obj /Fd"obj/third_party/blink/renderer/modules/unit_tests_cc.pdb"
../../third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_controller_test.cc(53,1):  error: [blink-gc] Class 'WaitForEvent' contains GC root in field 'element_'.
class WaitForEvent : public NativeEventListener {
^
../../third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_controller_test.cc(68,3):  note: [blink-gc] Field 'element_' defining a GC root declared here:
  Persistent<Element> element_;
  ^
```

Because I'm using NativeEventListener, it took longer that I want to admit to realise that the issue was that the class was GC'd and that I should override Trace and make `element_` a member. The error message seems to imply that the reader knows that the class is GC'd. Given that it can be very deep in the class hierarchy, could we make this clearer or maybe hint as to what the fix should/could be?
 

Sign in to add a comment