dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.19k stars 1.57k forks source link

1.17.0-dev.3.0 analyzer crashes analyzing Mojo app #26448

Closed zanderso closed 8 years ago

zanderso commented 8 years ago

Please let me know if you need repro instructions.

Analyzing dart-pkg mojo_dart_pingpong
Failed analyzing ['/b/build/slave/mojo/build/src/out/Release_asan_dcheck/gen/dart-pkg/mojo_dart_pingpong/lib/main.dart']
#0      SummaryResynthesizer._getLinkedSummaryOrThrow (package:analyzer/src/summary/resynthesize.dart:234)
#1      SummaryResynthesizer.getLibraryElement.<anonymous closure> (package:analyzer/src/summary/resynthesize.dart:182)
#10     AnalysisContextImpl.aboutToComputeResult (package:analyzer/src/context/context.dart:513)
#11     WorkItem.gatherInputs (package:analyzer/src/task/driver.dart:732)
#12     _WorkOrderDependencyWalker.getNextInput (package:analyzer/src/task/driver.dart:866)
#13     CycleAwareDependencyWalker.getNextStronglyConnectedComponent (package:analyzer/src/task/driver.dart:400)
#14     WorkOrder.moveNext.<anonymous closure> (package:analyzer/src/task/driver.dart:832)
#15     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212)
#16     WorkOrder.moveNext (package:analyzer/src/task/driver.dart:824)
#17     AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:106)
#18     AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:667)
#19     AnalysisContextImpl.computeLibraryElement (package:analyzer/src/context/context.dart:640)
#2      _HashVMBase&MapMixin&&_LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:259)
#20     AnalyzerImpl._resolveLibrary.<anonymous closure> (package:analyzer_cli/src/analyzer_impl.dart:246)
#21     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212)
#22     AnalyzerImpl._resolveLibrary (package:analyzer_cli/src/analyzer_impl.dart:245)
#23     AnalyzerImpl._analyzeSync (package:analyzer_cli/src/analyzer_impl.dart:159)
#24     AnalyzerImpl.analyzeSync (package:analyzer_cli/src/analyzer_impl.dart:120)
#25     Driver._runAnalyzer (package:analyzer_cli/src/driver.dart:575)
#26     Driver._analyzeAllImpl (package:analyzer_cli/src/driver.dart:213)
#27     Driver._analyzeAll.<anonymous closure> (package:analyzer_cli/src/driver.dart:156)
#28     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212)
#29     Driver._analyzeAll (package:analyzer_cli/src/driver.dart:155)
#3      SummaryResynthesizer.getLibraryElement (package:analyzer/src/summary/resynthesize.dart:181)
#30     Driver.start (package:analyzer_cli/src/driver.dart:136)
#31     main (file:///mnt/data/b/build/slave/dart-sdk-linux-dev/build/sdk/pkg/analyzer_cli/bin/analyzer.dart:11)
#32     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:259)
#33     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
#4      SdkSummaryResultProvider.compute (package:analyzer/src/summary/summary_sdk.dart:73)
#5      AnalysisContextImpl.aboutToComputeResult.<anonymous closure> (package:analyzer/src/context/context.dart:515)
#6      _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212)
#7      AnalysisContextImpl.aboutToComputeResult (package:analyzer/src/context/context.dart:513)
#8      AnalysisContextImpl.aboutToComputeResult.<anonymous closure> (package:analyzer/src/context/context.dart:524)
#9      _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212)
Bad state: Unable to find linked summary: dart:mojo.internal
zanderso commented 8 years ago

1.16.0-dev.5.5 Does not crash. I'll try to narrow it down a little more...

zanderso commented 8 years ago

1.17.0-dev.2.0 also does not crash.

bwilkerson commented 8 years ago

@stereotype441 @scheglov

scheglov commented 8 years ago

Yes, repro instructions would be very useful.

stereotype441 commented 8 years ago

@pq

zanderso commented 8 years ago

Apologies that the easiest way for me to tell you how to reproduce involves checking out and building Mojo:

Assuming you have depot_tools installed, on a Linux machine:

$ fetch mojo
$ cd src
$ ./mojo/tools/mojob.py gn --debug
$ ./mojo/tools/mojob.py build --debug

Then patch in a change with the SDK update and gclient sync:

$ git cl patch 1976783002
$ gclient sync
$ ./mojo/tools/mojob.py analyze-dart --debug

And you should see the analyzer crashing.

The SDK lives in //third_party/dart-sdk/dart-sdk in the checkout. Please let me know if there's anything else you need. Thanks!

pq commented 8 years ago

Thanks for the repro instructions. Taking a look now.

pq commented 8 years ago

@zanderso : are you able to hang tight with 1.17.0-dev.2.0 until we get this sorted?

zanderso commented 8 years ago

Yes, we were updating to grab configuration specific imports, so we're good with anything after 1.16.

pq commented 8 years ago

Great. Thanks @zanderso!

Follow-up question... How are you grabbing and installing the SDK into third_party? Is that scripted?

zanderso commented 8 years ago

It's scripted, with the version specified at the top of //tools/dart/update.py. For testing a fix, it should also be possible to move the one that's there out of the way, and e.g. symlink in a different one.

pq commented 8 years ago

Thanks! Working on a fix now. Hope to have something before the next dev build this week.

pq commented 8 years ago

Hmmmm. When I try and repro, I see this and a quick return:

[~/src/tmp/mojo/src] (scratch) $ ./mojo/tools/mojob.py analyze-dart --debug
Running python 'mojo/public/tools/dart_pkg_static_analysis.py' '--dart-pkg-dir=out/Debug/gen/dart-pkg' '--dart-sdk=third_party/dart-sdk/dart-sdk' '--package-root=out/Debug/gen/dart-pkg/packages' ...

The build step fails for me too (but I'm not sure that matters). I am on a mac though...

Quick thought. It would be great if I could just repro with a direct call to the analyzer. Something like?

third_party/dart-sdk/dart-sdk/bin/dartanalyzer --dart-sdk=third_party/dart-sdk/dart-sdk --package-root=out/Debug/gen/dart-pkg/packages --packages=out/Debug/gen/dart-pkg  ...

On the bright side, I have an idea of what's up. It would just be awesome to actually repro it so I can get some confidence that we've got it fixed. 😄

Here's the build failure if it helps at all:

[~/src/tmp/mojo/src] (scratch) $ ./mojo/tools/mojob.py build --debug
Building in out/Debug ...
ninja: Entering directory `out/Debug'
[184/4549] CXX obj/third_party/skia/src/ports/skia.SkFontHost_mac.o
FAILED: obj/third_party/skia/src/ports/skia.SkFontHost_mac.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/third_party/skia/src/ports/skia.SkFontHost_mac.o.d -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -DDISABLE_NACL -DCHROMIUM_BUILD -DCR_CLANG_REVISION=259396-1 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DSK_GAMMA_SRGB -DSK_GAMMA_CONTRAST=0.0 -DSK_HIGH_QUALITY_IS_LANCZOS -DSK_DEFAULT_FONT_CACHE_LIMIT=20971520 -DSK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS -DSK_SUPPORT_LEGACY_SHADERBITMAPTYPE -DSK_SUPPORT_GPU=1 -DSK_BUILD_FOR_MAC -I../.. -Igen -I../../third_party/skia/include/private -I../../third_party/skia/src/core -I../../third_party/skia/src/image -I../../third_party/skia/src/opts -I../../third_party/skia/src/pdf -I../../third_party/skia/src/ports -I../../third_party/skia/src/sfnt -I../../third_party/skia/src/utils -I../../third_party/skia/src/lazy -I../../third_party/skia/include/utils/mac -I../../third_party/skia/include/utils/ios -I../../skia/config -I../../skia/ext -I../../third_party/skia/include/c -I../../third_party/skia/include/config -I../../third_party/skia/include/core -I../../third_party/skia/include/effects -I../../third_party/skia/include/images -I../../third_party/skia/include/lazy -I../../third_party/skia/include/pathops -I../../third_party/skia/include/pdf -I../../third_party/skia/include/pipe -I../../third_party/skia/include/ports -I../../third_party/skia/include/utils -I../../third_party/skia/include/gpu -I../../third_party/skia/src/gpu -I../../third_party/zlib -fno-strict-aliasing -fstack-protector-all -arch x86_64 -fcolor-diagnostics -fvisibility=hidden -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.9 -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -Xclang -plugin-arg-find-bad-constructs -Xclang check-templates -Xclang -add-plugin -Xclang find-bad-constructs -O0 -g2 -Wno-inconsistent-missing-override -Wendif-labels -Werror -Wno-missing-field-initializers -Wpartial-availability -Wno-c++11-narrowing -Wno-char-subscripts -Wno-covered-switch-default -Wno-deprecated-register -Wno-shift-negative-value -Wno-constant-conversion -fvisibility-inlines-hidden -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++11 -fno-rtti -fno-exceptions -c ../../third_party/skia/src/ports/SkFontHost_mac.cpp -o obj/third_party/skia/src/ports/skia.SkFontHost_mac.o
../../third_party/skia/src/ports/SkFontHost_mac.cpp:315:53: error: 'kCGEncodingMacRoman' is deprecated: first deprecated in OS X 10.9 [-Werror,-Wdeprecated-declarations]
    CGContextSelectFont(cgContext, "Helvetica", 16, kCGEncodingMacRoman);
                                                    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h:57:3: note: 'kCGEncodingMacRoman' has been explicitly marked deprecated here
  kCGEncodingMacRoman
  ^
../../third_party/skia/src/ports/SkFontHost_mac.cpp:315:5: error: 'CGContextSelectFont' is deprecated: first deprecated in OS X 10.9 [-Werror,-Wdeprecated-declarations]
    CGContextSelectFont(cgContext, "Helvetica", 16, kCGEncodingMacRoman);
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h:1031:16: note: 'CGContextSelectFont' has been explicitly marked deprecated here
CG_EXTERN void CGContextSelectFont(CGContextRef __nullable c,
               ^
../../third_party/skia/src/ports/SkFontHost_mac.cpp:320:5: error: 'CGContextShowTextAtPoint' is deprecated: first deprecated in OS X 10.9 [-Werror,-Wdeprecated-declarations]
    CGContextShowTextAtPoint(cgContext, -1, 0, "|", 1);
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h:1045:16: note: 'CGContextShowTextAtPoint' has been explicitly marked deprecated here
CG_EXTERN void CGContextShowTextAtPoint(CGContextRef __nullable c,
               ^
3 errors generated.
[193/4549] CXX obj/third_party/skia/src/gpu/skia.GrLayerCache.o
ninja: build stopped: subcommand failed.
zanderso commented 8 years ago

It looks like the build is failing on some Mac-specific stuff. The Mac build is not well-supported. The build assembles some stuff in the output directory (e.g. the package root) that the analysis step needs. If you don't have access to a Linux machine, I can put together a self-contained repro sometime tomorrow.

pq commented 8 years ago

That would be really great. I don't have a linux box handy...

pq commented 8 years ago

Popping up, I'll speculate about what I think is going on and get some of the right folks thinking about it.

@stereotype441, @bwilkerson : the issue, almost certainly, is in the use of a summarized SDK in the presence of SDK extensions. A short term fix will be to skip the summarized SDK in case an sdk_ext (or _embedder.yaml) but we should be thinking about something better.

pq commented 8 years ago

FWIW I've opened a tracking bug for the meta issue of making summaries work in the presence of embedders and sdk extensions here: https://github.com/dart-lang/sdk/issues/26467.

pq commented 8 years ago

Repro'ed locally and confirmed that using the summarized SDK is the cause. Patch on the way.

Thanks @zanderso for the help!

pq commented 8 years ago

This should be fixed as of https://github.com/dart-lang/sdk/commit/31a03ec31b1dc1c7db8b6cecd61fbca746766a73.

The next dev build (> 3.0) should be safe.

pq commented 8 years ago

dev-4.1 is up. Fingers crossed we're good!

zanderso commented 8 years ago

Thanks! I'll give the roll into Mojo a try on Monday =)

pq commented 8 years ago

Awesome. Let me know how it goes!

zanderso commented 8 years ago

Verified that the crash is gone after rolling Mojo to 1.17dev-4.1. Thanks!

pq commented 8 years ago

Great. Thanks for following up!