Closed Bug 1577272 Opened 5 months ago Closed 5 months ago

TestNoRefcountedInsideLambdas tests fail with -std=gnu++17

Categories

(Firefox Build System :: Source Code Analysis, defect)

defect
Not set

Tracking

(firefox71 fixed)

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: froydnj, Assigned: froydnj)

References

Details

Attachments

(1 file)

/builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ -isysroot /builds/worker/workspace/build/src/MacOSX10.11.sdk -std=gnu++17 --target=x86_64-apple-darwin -o TestNoRefcountedInsideLambdas.o -c  -DNDEBUG=1 -DTRIMMED=1 -I/builds/worker/workspace/build/src/build/clang-plugin/tests -I/builds/worker/workspace/build/src/obj-firefox/build/clang-plugin/tests -I/builds/worker/workspace/build/src/obj-firefox/dist/include -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nspr -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nss -fPIC -DMOZILLA_CLIENT -include /builds/worker/workspace/build/src/obj-firefox/mozilla-config.h -Qunused-arguments -U_FORTIFY_SOURCE -fno-common -Qunused-arguments -fno-sized-deallocation -fno-aligned-new -fsanitize=address -fcrash-diagnostics-dir=/builds/worker/artifacts -fcrash-diagnostics-dir=/builds/worker/artifacts -U_FORTIFY_SOURCE -fno-common -fno-exceptions -fno-strict-aliasing -stdlib=libc++ -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -fsyntax-only -Xclang -verify -ferror-limit=0 -Wno-invalid-noreturn -g -Xclang -load -Xclang /builds/worker/workspace/build/src/obj-firefox/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -fno-omit-frame-pointer -funwind-tables -Werror  -MD -MP -MF .deps/TestNoRefcountedInsideLambdas.o.pp   /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp
error: 'error' diagnostics seen but not expected:
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 397: address of stack memory associated with local variable 'ptr' returned
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 407: address of stack memory associated with local variable 'sp' returned
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 417: address of stack memory associated with local variable 'ptr' returned
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 427: address of stack memory associated with local variable 'sp' returned
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 517: address of stack memory associated with local variable 'ptr' returned
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 527: address of stack memory associated with local variable 'sp' returned
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 537: address of stack memory associated with local variable 'ptr' returned
  File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 547: address of stack memory associated with local variable 'sp' returned
8 errors generated.

I'm assuming these are new errors in C++17 mode, which:

https://github.com/llvm/llvm-project/blob/master/clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp#L176-L186

suggests is correct. I guess we should just add the appropriate expected-error line conditional on the C++ version? Or are those tests meant to be checking something else that hasn't been implemented yet?

Flags: needinfo?(bpostelnicu)

These are old examples that we've had in place, and we intentionally wrote them in order to test the relaxing of allowing lambdas to capture raw pointers to refcounted objects by reference.
Long time ago our analysis would have yield results like:

 void foo() {
   R* ptr;
   SmartPtr<R> sp;
   take([&](R* argptr) {
     R* localptr;
     ptr->method(); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
     argptr->method();
     localptr->method();
   });

In conclusion we should mark the diagnostic messages with expected-error.

Flags: needinfo?(bpostelnicu)

OK, so if I mark all the lines with expected-error (conditional on C++17), I get:

INFO -  error: 'error' diagnostics expected but not seen:
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 398: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 412: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 426: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 440: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 534: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 548: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 562: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 576: address of stack memory associated with local variable 'sp' returned
INFO -  error: 'warning' diagnostics seen but not expected:
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 398: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 412: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 426: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 440: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 534: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 548: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 562: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 576: address of stack memory associated with local variable 'sp' returned
INFO -  16 errors generated.

https://treeherder.mozilla.org/#/jobs?repo=try&revision=a32d233374ef69b59899195d4247d5264a9ec415

OK, fine, they're...warnings now (instead of errors, see comment 0)? But if I annotate with expected-warning instead, I get:

INFO -  error: 'error' diagnostics seen but not expected:
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 398: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 412: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 426: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 440: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 534: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 548: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 562: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 576: address of stack memory associated with local variable 'sp' returned
INFO -  error: 'warning' diagnostics expected but not seen:
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 398: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 412: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 426: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 440: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 534: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 548: address of stack memory associated with local variable 'sp' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 562: address of stack memory associated with local variable 'ptr' returned
INFO -    File /builds/worker/workspace/build/src/build/clang-plugin/tests/TestNoRefcountedInsideLambdas.cpp Line 576: address of stack memory associated with local variable 'sp' returned
INFO -  16 errors generated.

https://treeherder.mozilla.org/#/jobs?repo=try&revision=6edd1bf7afb292c0fc3d9ddb3735e76425e9361a

which is the exact opposite of what I was seeing before. What is going on?

Flags: needinfo?(bpostelnicu)

Oh, never mind. Stupid ccov build runs without --enable-warnings-as-errors, which is what the first set is from.

Flags: needinfo?(bpostelnicu)

clang produces these errors itself, but only in C++17 mode.

Pushed by nfroyd@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/21386d8f21ae
annotate some refcounted lambda tests with expected errors for C++17; r=andi
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
Assignee: nobody → nfroyd
You need to log in before you can comment on or make changes to this bug.