Skip to content

Crash when hot reloading on macOS - Crash occurred when compiling unknown function in unoptimized JIT mode in unknown pass #140878

Description

@alexvoina

Steps to reproduce

My app is crashing when modifying and hot reloading some Flutter code inside a custom painter that calls some native ffi function. I'm not sure if the problem is related to the native function or the custom painter

I've seen this similar issue (#140131) which was closed recently, but unfortunately the conversation didn't provide a clear answer to me.

I tried disabling hardened runtime & also enabling it & making sure the "Allow JIT .. " flag is set.

Pasting the stack trace below

`

./../third_party/dart/runtime/vm/symbols.cc: 355: error: expected: thread->CanAcquireSafepointLocks()
version=3.2.3 (stable) (Tue Dec 5 17:58:33 2023 +0000) on "macos_arm64"
pid=80783, thread=42499, isolate_group=main(0x10685ea00), isolate=(nil)(0x0)
os=macos, arch=arm64, comp=no, sim=no
isolate_instructions=109d3c920, vm_instructions=109d3c920
fp=16de8fde0, sp=16de8fda0, pc=109ea74f8
  pc 0x0000000109ea74f8 fp 0x000000016de8fde0 dart::Profiler::DumpStackTrace(void*)+0x90
  pc 0x0000000109d3cb6c fp 0x000000016de8fe00 dart::Assert::Fail(char const*, ...) const+0x28
  pc 0x0000000109f1a54c fp 0x000000016de8fec0 dart::StringPtr dart::Symbols::NewSymbol<dart::CharArray<unsigned char>>(dart::Thread*, dart::CharArray<unsigned char> const&)+0x27c
  pc 0x0000000109f1a06c fp 0x000000016de8ff40 dart::Symbols::FromUTF8(dart::Thread*, unsigned char const*, long)+0xc0
  pc 0x000000010a0cb608 fp 0x000000016de8ff80 dart::kernel::TranslationHelper::DartSymbolObfuscate(dart::kernel::StringIndex) const+0xcc
  pc 0x000000010a0df18c fp 0x000000016de90060 dart::kernel::ScopeBuilder::AddVariableDeclarationParameter(long, dart::kernel::ScopeBuilder::ParameterTypeCheckMode, dart::kernel::ProcedureAttributesMetadata const&)+0xe8
  pc 0x000000010a0db95c fp 0x000000016de901e0 dart::kernel::ScopeBuilder::BuildScopes()+0x12dc
  pc 0x0000000109ea5078 fp 0x000000016de90540 dart::ParsedFunction::EnsureKernelScopes()+0x40
  pc 0x000000010a0a6044 fp 0x000000016de90580 dart::kernel::StreamingFlowGraphBuilder::ParseKernelASTFunction()+0x6c
  pc 0x000000010a0a5e60 fp 0x000000016de90640 dart::kernel::StreamingFlowGraphBuilder::BuildGraph()+0xb8
  pc 0x000000010a0b7b08 fp 0x000000016de90920 dart::kernel::FlowGraphBuilder::BuildGraph()+0x70
  pc 0x0000000109f3aed0 fp 0x000000016de90b40 dart::DartCompilationPipeline::BuildFlowGraph(dart::Zone*, dart::ParsedFunction*, dart::ZoneGrowableArray<dart::ICData const*>*, long, bool)+0x4c
  pc 0x0000000109f3c064 fp 0x000000016de912f0 dart::CompileParsedFunctionHelper::Compile(dart::CompilationPipeline*)+0x534
  pc 0x0000000109f3c9ac fp 0x000000016de91a30 dart::CompileFunctionHelper(dart::CompilationPipeline*, dart::Function const&, bool, long)+0x388
  pc 0x0000000109f3cdc0 fp 0x000000016de91a70 dart::Compiler::EnsureUnoptimizedCode(dart::Thread*, dart::Function const&)+0xc0
  pc 0x0000000109ef065c fp 0x000000016de91ad0 dart::DeoptimizeAt(dart::Thread*, dart::Code const&, dart::StackFrame*)+0x6c
  pc 0x0000000109ef3b2c fp 0x000000016de91bc0 std::_LIBCPP_ABI_NAMESPACE::__function::__func<dart::DeoptimizeFunctionsOnStack()::$_0::operator()() const::'lambda'(dart::Isolate*), std::_LIBCPP_ABI_NAMESPACE::allocator<dart::DeoptimizeFunctionsOnStack()::$_0::operator()() const::'lambda'(dart::Isolate*)>, void (dart::Isolate*)>::operator()(dart::Isolate*&&)+0x114
  pc 0x0000000109dbabac fp 0x000000016de91c20 dart::IsolateGroup::ForEachIsolate(std::_LIBCPP_ABI_NAMESPACE::function<void (dart::Isolate*)>, bool)+0x6c
  pc 0x0000000109ef37f0 fp 0x000000016de91c70 dart::LambdaCallable<dart::DeoptimizeFunctionsOnStack()::$_0>::Call()+0x54
  pc 0x0000000109dc0fe4 fp 0x000000016de91d40 dart::IsolateGroup::RunWithStoppedMutatorsCallable(dart::Callable*, dart::Callable*, bool)+0x1f4
  pc 0x0000000109ef08f4 fp 0x000000016de91dc0 dart::DeoptimizeFunctionsOnStack()+0xa8
  pc 0x0000000109da0834 fp 0x000000016de91f30 dart::Debugger::DeoptimizeWorld()+0xbc
  pc 0x0000000109da2c84 fp 0x000000016de91fd0 dart::Debugger::SetBreakpoint(dart::GrowableHandlePtrArray<dart::Script const> const&, dart::TokenPosition, dart::TokenPosition, long, long, dart::Function const&)+0x15c
  pc 0x0000000109da35dc fp 0x000000016de92090 dart::Debugger::BreakpointLocationAtLineCol(dart::String const&, long, long)+0x238
  pc 0x0000000109da370c fp 0x000000016de920d0 dart::Debugger::SetBreakpointAtLineCol(dart::String const&, long, long)+0x2c
  pc 0x0000000109f07388 fp 0x000000016de92140 dart::AddBreakpointCommon(dart::Thread*, dart::JSONStream*, dart::String const&)+0x12c
  pc 0x0000000109ef88f8 fp 0x000000016de92760 dart::Service::InvokeMethod(dart::Isolate*, dart::Array const&, bool)+0x2c4
  pc 0x0000000109ef8ed4 fp 0x000000016de92790 dart::Service::HandleIsolateMessage(dart::Isolate*, dart::Array const&)+0x2c
  pc 0x0000000109dbd8fc fp 0x000000016de92d40 dart::IsolateMessageHandler::HandleMessage(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<dart::Message, std::_LIBCPP_ABI_NAMESPACE::default_delete<dart::Message>>)+0x1dc
  pc 0x0000000109de8328 fp 0x000000016de92dc0 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)+0x144
  pc 0x0000000109de8760 fp 0x000000016de92e00 dart::MessageHandler::HandleOOBMessages()+0x60
  pc 0x000000010a194d90 fp 0x000000016de92ea0 Dart_HandleServiceMessages+0x150
  pc 0x0000000109dc2a5c fp 0x000000016de92ef0 dart::Isolate::PauseEventHandler()+0xa0
  pc 0x0000000109d9c104 fp 0x000000016de930c0 dart::Debugger::Pause(dart::ServiceEvent*)+0x110
  pc 0x0000000109d9ba48 fp 0x000000016de93210 dart::Debugger::PauseRequest(dart::ServiceEvent::EventKind)+0xcc
  pc 0x0000000109dbf648 fp 0x000000016de93230 dart::Isolate::PausePostRequest()+0x28

..
..

  pc 0x0000000287ac4648 fp 0x000000016de949d8 sp 0x000000016de94958 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de94a20 sp 0x000000016de949e8 [Optimized] PaintingContext.paintChild
  pc 0x0000000287f0a718 fp 0x000000016de94aa8 sp 0x000000016de94a30 [Optimized] RenderStack.paint
  pc 0x0000000287ac4648 fp 0x000000016de94b38 sp 0x000000016de94ab8 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de94b80 sp 0x000000016de94b48 [Optimized] PaintingContext.paintChild
  pc 0x0000000287ac1fa8 fp 0x000000016de94bb8 sp 0x000000016de94b90 [Optimized] _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin@1195160605.paint
  pc 0x0000000287ac4534 fp 0x000000016de94c48 sp 0x000000016de94bc8 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de94c90 sp 0x000000016de94c58 [Optimized] PaintingContext.paintChild
  pc 0x0000000287ac1fa8 fp 0x000000016de94cc8 sp 0x000000016de94ca0 [Optimized] _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin@1195160605.paint
  pc 0x0000000287ac456c fp 0x000000016de94d58 sp 0x000000016de94cd8 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de94da0 sp 0x000000016de94d68 [Optimized] PaintingContext.paintChild
  pc 0x0000000287ac1fa8 fp 0x000000016de94dd8 sp 0x000000016de94db0 [Optimized] _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin@1195160605.paint
  pc 0x0000000287ac4550 fp 0x000000016de94e68 sp 0x000000016de94de8 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de94eb0 sp 0x000000016de94e78 [Optimized] PaintingContext.paintChild
  pc 0x000000017a70791c fp 0x000000016de94f00 sp 0x000000016de94ec0 [Optimized] RenderShiftedBox.paint
  pc 0x0000000287ac4648 fp 0x000000016de94f90 sp 0x000000016de94f10 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de94fd8 sp 0x000000016de94fa0 [Optimized] PaintingContext.paintChild
  pc 0x0000000287f0a718 fp 0x000000016de95060 sp 0x000000016de94fe8 [Optimized] RenderStack.paint
  pc 0x0000000287ac4648 fp 0x000000016de950f0 sp 0x000000016de95070 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de95138 sp 0x000000016de95100 [Optimized] PaintingContext.paintChild
  pc 0x0000000287ac1fa8 fp 0x000000016de95170 sp 0x000000016de95148 [Optimized] _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin@1195160605.paint
  pc 0x0000000287ac45bc fp 0x000000016de95200 sp 0x000000016de95180 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000280082500 fp 0x000000016de95248 sp 0x000000016de95210 [Optimized] PaintingContext.paintChild
  pc 0x0000000281e6a188 fp 0x000000016de95290 sp 0x000000016de95258 [Unoptimized] _RenderSingleChildViewport@1781426794.paint.paintContents
  pc 0x0000000281e68dfc fp 0x000000016de952e0 sp 0x000000016de952a0 [Unoptimized] _RenderSingleChildViewport@1781426794.paint
  pc 0x0000000287ac4648 fp 0x000000016de95370 sp 0x000000016de952f0 [Optimized] RenderObject._paintWithContext@1208266271
  pc 0x0000000287f72e00 fp 0x000000016de95400 sp 0x000000016de95380 [Optimized] PaintingContext._repaintCompositedChild@1208266271
  pc 0x0000000178637d64 fp 0x000000016de95458 sp 0x000000016de95410 [Unoptimized] PaintingContext.repaintCompositedChild
  pc 0x0000000287afc158 fp 0x000000016de95538 sp 0x000000016de95468 [Optimized] PipelineOwner.flushPaint
  pc 0x0000000287afc334 fp 0x000000016de95618 sp 0x000000016de95548 [Optimized] PipelineOwner.flushPaint
  pc 0x000000016f83ba64 fp 0x000000016de95660 sp 0x000000016de95628 [Unoptimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding@1086399801.drawFrame
  pc 0x000000016f831170 fp 0x000000016de956b8 sp 0x000000016de95670 [Unoptimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding@1086399801.drawFrame
  pc 0x000000016f830a5c fp 0x000000016de956f0 sp 0x000000016de956c8 [Unoptimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding@1086399801._handlePersistentFrameCallback@1203452173
  pc 0x000000016f830958 fp 0x000000016de95730 sp 0x000000016de95700 [Unoptimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding&ServicesBinding&PaintingBinding&SemanticsBinding&RendererBinding@1086399801._handlePersistentFrameCallback@1203452173
  pc 0x0000000287f0dc00 fp 0x000000016de95820 sp 0x000000016de95740 [Optimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding@1086399801._invokeFrameCallback@1200222615
  pc 0x0000000287f0bec4 fp 0x000000016de95950 sp 0x000000016de95830 [Optimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding@1086399801.handleDrawFrame
  pc 0x0000000179317ce0 fp 0x000000016de95988 sp 0x000000016de95960 [Unoptimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding@1086399801._handleDrawFrame@1200222615
  pc 0x0000000179317a30 fp 0x000000016de959c0 sp 0x000000016de95998 [Unoptimized] _WidgetsFlutterBinding&BindingBase&GestureBinding&SchedulerBinding@1086399801._handleDrawFrame@1200222615
  pc 0x000000011f69a6a0 fp 0x000000016de959f8 sp 0x000000016de959d0 [Unoptimized] _invoke@15065589
  pc 0x000000011f6b587c fp 0x000000016de95a38 sp 0x000000016de95a08 [Unoptimized] PlatformDispatcher._drawFrame@15065589
  pc 0x000000011f6b5520 fp 0x000000016de95a68 sp 0x000000016de95a48 [Unoptimized] _drawFrame@15065589
  pc 0x000000011f6b544c fp 0x000000016de95a90 sp 0x000000016de95a78 [Unoptimized] _drawFrame@15065589
  pc 0x000000011e783404 fp 0x000000016de95b60 sp 0x000000016de95aa0 [Stub] InvokeDartCode
=== Crash occurred when compiling package:my_file.dart_MyCustomPainter_paint in unoptimized JIT mode in unknown pass
=== Flow Graph not available
Reloaded 2 of 2052 libraries in 789ms (compile: 53 ms, reload: 183 ms, reassemble: 206 ms).
Lost connection to device.

Exited.
`

Expected results

app should reload without crashing

Actual results

app crashes when I comment out some code inside paint() method of a CustomPainter & hot reload

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.2.1 23C71 darwin-arm64, locale en-RO)
    • Flutter version 3.16.5 on channel stable at /Users/alexvocode/work/vocode/libraries/third-party/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (2 weeks ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolec: fatal crashCrashes that terminate the processdependency: dartDart team may need to help usengineflutter/engine related. See also e: labels.r: fixedIssue is closed as already fixed in a newer versiont: hot reloadReloading code during "flutter run"team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions