Segfault in bv_rewriter::mk_mul_eq() - z3

I have a short (4-line) program that terminates with a segmentation fault on one system but not on another.
(set-logic QF_FP)
(declare-fun s0 () (_ FloatingPoint 11 53))
(assert (fp.isSubnormal (fp.mul roundNearestTiesToEven s0 s0)))
(check-sat)
This program should produce (sat), but Z3 crashes, with the following backtrace:
(gdb) bt
#0 bv_rewriter::mk_mul_eq (this=this#entry=0x1654380, lhs=lhs#entry=0x16149e8, rhs=rhs#entry=0x16b40b8, result=...) at ../src/ast/rewriter/bv_rewriter.cpp:2074
#1 0x0000000000e7ed3b in bv_rewriter::mk_eq_core (this=this#entry=0x1654380, lhs=0x16b40b8, rhs=0x16149e8, result=...) at ../src/ast/rewriter/bv_rewriter.cpp:2118
#2 0x0000000000eab20c in reduce_app_core (result=..., args=0x16c3588, num=2, f=0x16ad9b8, this=0x1654308) at ../src/ast/rewriter/th_rewriter.cpp:173
#3 th_rewriter_cfg::reduce_app (this=0x1654308, f=0x16ad9b8, num=2, args=0x16c3588, result=..., result_pr=...) at ../src/ast/rewriter/th_rewriter.cpp:554
#4 0x0000000000eae001 in rewriter_tpl<th_rewriter_cfg>::process_app<false> (this=0x16541c8, t=0x163e6a8, fr=...) at ../src/ast/rewriter/rewriter_def.h:215
#5 0x0000000000eae4b5 in rewriter_tpl<th_rewriter_cfg>::resume_core<false> (this=0x16541c8, result=..., result_pr=...) at ../src/ast/rewriter/rewriter_def.h:602
#6 0x0000000000dc31e5 in propagate_values_tactic::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) ()
#7 0x0000000000e1a2ae in cleanup_tactical::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) ()
#8 0x0000000000e1ef61 in and_then_tactical::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) ()
#9 0x0000000000e1fa30 in and_then_tactical::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) ()
#10 0x0000000000e1fa30 in and_then_tactical::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) ()
#11 0x0000000000e1fa30 in and_then_tactical::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) ()
#12 0x0000000000e35364 in exec(tactic&, ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) ()
#13 0x0000000000e357f9 in check_sat(tactic&, ref<goal>&, ref<model>&, obj_ref<app, ast_manager>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&, std::string&) ()
#14 0x0000000000ca18d7 in tactic2solver::check_sat_core(unsigned int, expr* const*) ()
#15 0x0000000000ca00d6 in solver_na2as::check_sat(unsigned int, expr* const*) ()
#16 0x0000000000ca404b in combined_solver::check_sat (this=0x16a0868, num_assumptions=<optimized out>, assumptions=0x16a2b90) at ../src/solver/combined_solver.cpp:235
#17 0x0000000000bead59 in cmd_context::check_sat (this=0x7fffffffc920, num_assumptions=0, assumptions=assumptions#entry=0x16a2b90)
at ../src/cmd_context/cmd_context.cpp:1459
#18 0x0000000000bc8e38 in smt2::parser::parse_check_sat (this=this#entry=0x7fffffffbee0) at ../src/parsers/smt2/smt2parser.cpp:2170
#19 0x0000000000bd1d18 in parse_cmd (this=0x7fffffffbee0) at ../src/parsers/smt2/smt2parser.cpp:2500
#20 smt2::parser::operator() (this=this#entry=0x7fffffffbee0) at ../src/parsers/smt2/smt2parser.cpp:2655
#21 0x0000000000bc1d28 in parse_smt2_commands (ctx=..., is=..., interactive=<optimized out>, ps=...) at ../src/parsers/smt2/smt2parser.cpp:2704
#22 0x0000000000411ec5 in read_smtlib2_commands(char const*) ()
#23 0x0000000000412c83 in main (argc=<optimized out>, argv=<optimized out>) at ../src/shell/main.cpp:342
Since this program works on one system (Linux v3.13) but fails on another (Linux v2.6.32), I presume this fault has something to do with the OS / configuration. Both systems run Z3 v4.4.2. On the system where Z3 crashes, the last Git commit ID is a2fb4fc589d54ff776ec9b20a0849b9926fbb345 [January 4th].
Can someone please give me any hints about possible causes of the crash? Thanks much in advance!

Related

Debugging segfault when calling ComputeSignedDistancePairwiseClosestPoints in PyDrake

I'm running an optimization loop that repeatedly calls ComputeSignedDistancePairwiseClosestPoints. After hundreds of cumulative hours of running this without problems, I've encountered a segfault and am looking for guidance on debugging it (or if it's a bug in Drake, possible temporary workarounds).
As suggested in this post, upon initialization, I store diagram, plant, and scene graph contexts, and before calling ComputeSignedDistancePairwiseClosestPoints, I call the query object output port evaluated at the stored scene graph context. Here is a rough outline of the relevant code structure:
class SimplifiedClass:
def __init__(self, ...):
# initializing plant, contexts, and query object port
self.diagram = function_generating_diagram_with_plant(...)
self.plant = self.diagram.GetSubsystemByName("plant")
self.scene_graph = self.diagram.GetSubsystemByName("scene_graph")
_diag_context = self.diagram.CreateDefaultContext()
self.plant_context = self.plant.GetMyMutableContextFromRoot(_diag_context)
self.sg_context = self.scene_graph.GetMyMutableContextFromRoot(_diag_context)
self.qo_port = self.scene_graph.get_query_output_port()
#property
def query_object(self):
return self.qo_port.Eval(self.sg_context)
def function_that_computes_signed_distances(self, ...):
# this function calls ComputeSignedDistancePairClosestPoints()
# it is called repeatedly in an optimization loop
# line that computes signed distance pairs after other operations
sdps = self.query_object.ComputeSignedDistancePairwiseClosestPoints(
max_distance=some_number
)
I can reproduce the segfault by fixing the random seed appropriately, and I find that when changing the max_distance parameter of ComputeSignedDistancePairwiseClosestPoints, the segfault no longer occurs for this specific seed.
I printed a gdb backtrace which returns the following:
#0 0x00007f21a9149be5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#1 0x00007f21a914cc46 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#2 0x00007f21a914cca5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#3 0x00007f21a914cca5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#4 0x00007f21a914cca5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#5 0x00007f21a914cca5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#6 0x00007f21a914cca5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#7 0x00007f21a914cca5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#8 0x00007f21a914cca5 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#9 0x00007f21a914d61b in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#10 0x00007f21a914ba3a in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#11 0x00007f21a914bbdc in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#12 0x00007f21a919f324 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#13 0x00007f21a9165123 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#14 0x00007f21a918961a in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#15 0x00007f21a918d29d in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#16 0x00007f21a918fdd2 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#17 0x00007f21a92a9496 in void drake::geometry::internal::shape_distance::CalcDistanceFallback<double>(fcl::CollisionObject<double> const&, fcl::CollisionObject<double> const&, fcl::DistanceRequest<double> const&, drake::geometry::SignedDistancePair<double>*) () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#18 0x00007f21a92a9aa5 in bool drake::geometry::internal::shape_distance::Callback<double>(fcl::CollisionObject<double>*, fcl::CollisionObject<double>*, void*, double&) ()
from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#19 0x00007f21a91e98ca in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#20 0x00007f21a91e99b2 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#21 0x00007f21a91e998b in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#22 0x00007f21a91e998b in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#23 0x00007f21a91e998b in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#24 0x00007f21a91e99b2 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#25 0x00007f21a91e99b2 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#26 0x00007f21a91e998b in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#27 0x00007f21a91e9a26 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#28 0x00007f21a933a01e in drake::geometry::internal::ProximityEngine<double>::ComputeSignedDistancePairwiseClosestPoints(std::unordered_map<drake::geometry::GeometryId, drake::math::RigidTransform<double>, std::hash<drake::geometry::GeometryId>, std::equal_to<drake::geometry::GeometryId>, std::allocator<std::pair<drake::geometry::GeometryId const, drake::math::RigidTransform<double> > > > const&, double) const ()
from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#29 0x00007f21a93ab1fc in drake::geometry::QueryObject<double>::ComputeSignedDistancePairwiseClosestPoints(double) const () from /opt/drake/lib/python3.10/site-packages/pydrake/common/../../../../libdrake.so
#30 0x00007f20bf6f2327 in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/geometry.cpython-310-x86_64-linux-gnu.so
#31 0x00007f20bf547c4f in ?? () from /opt/drake/lib/python3.10/site-packages/pydrake/geometry.cpython-310-x86_64-linux-gnu.so
#32 0x00005604e39c1b5e in ?? ()
#33 0x00005604e39b87db in _PyObject_MakeTpCall ()
#34 0x00005604e39d066b in ?? ()
#35 0x00005604e39ac2fc in _PyEval_EvalFrameDefault ()
#36 0x00005604e39c23ac in _PyFunction_Vectorcall ()
#37 0x00005604e39ab14a in _PyEval_EvalFrameDefault ()
#38 0x00005604e39d0391 in ?? ()
#39 0x00005604e39ac2fc in _PyEval_EvalFrameDefault ()
#40 0x00005604e39c23ac in _PyFunction_Vectorcall ()
#41 0x00005604e39ab14a in _PyEval_EvalFrameDefault ()
#42 0x00005604e39c23ac in _PyFunction_Vectorcall ()
... (more in this trace omitted since it's not Drake-specific)

FunctionType::get(Type *Result, bool isVarArg ) with void argument causes clang to crash with exit code 139

I am using LLVM Legacy Pass Manager to insert a function call in a factorial code, the function prototype:
void func (void);
Here is the code snippet I use to define the function inside LLVM pass manager:
Type *retTy = Type::getVoidTy(context);
FunctionType *funcTy = FunctionType::get(retTy, false);
module->getOrInsertFunction(funcName, funcTy);
based on this definition in llvm/IR/DerivedTypes.h
/// Create a FunctionType taking no parameters.
static FunctionType *get(Type *Result, bool isVarArg);
However, clang crashes with the following output:
Stack dump:
0. Program arguments: clang -flegacy-pass-manager -Xclang -load -Xclang ../libSkeletonPass.so -S -emit-llvm factorial.c
1. <eof> parser at end of file
2. Per-function optimization
3. Running pass 'Unnamed pass: implement Pass::getPassName()' on function '#factorial'
#0 0x00007f885f07ad01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3fd01)
#1 0x00007f885f078a3e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3da3e)
#2 0x00007f885f07a0ab llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3f0ab)
#3 0x00007f885efa6dff (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bdff)
#4 0x00007f885dd20520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007f885f204b9c (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xfc9b9c)
#6 0x00007f885f203438 llvm::FunctionType::get(llvm::Type*, bool) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xfc8438)
#7 0x00007f885bbb5394 (anonymous namespace)::getVoidFuncVoid(llvm::StringRef, llvm::LLVMContext&, llvm::Module*) Skeleton.cpp:0:0
#8 0x00007f885bbb54d9 (anonymous namespace)::SkeletonPass::runOnFunction(llvm::Function&) Skeleton.cpp:0:0
#9 0x00007f885f1b53c0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf7a3c0)
#10 0x00007f885f1b4dae llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf79dae)
#11 0x00007f885f1bc79c llvm::legacy::FunctionPassManager::run(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf8179c)
#12 0x00007f8866366b4b clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1859b4b)
#13 0x00007f8866689855 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b7c855)
#14 0x00007f8865511834 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xa04834)
#15 0x00007f8866685b71 clang::CodeGenAction::ExecuteAction() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b78b71)
#16 0x00007f8867021b57 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x2514b57)
#17 0x00007f8866f793a6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x246c3a6)
#18 0x00007f886709b45b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x258e45b)
#19 0x000000000041328b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-14/bin/clang+0x41328b)
#20 0x00000000004114bc (/usr/lib/llvm-14/bin/clang+0x4114bc)
#21 0x00007f8866bf7ed2 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20eaed2)
#22 0x00007f885efa6b6d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bb6d)
#23 0x00007f8866bf79c0 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20ea9c0)
#24 0x00007f8866bc2183 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b5183)
#25 0x00007f8866bc240a clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b540a)
#26 0x00007f8866bdc507 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20cf507)
#27 0x0000000000410f26 main (/usr/lib/llvm-14/bin/clang+0x410f26)
#28 0x00007f885dd07d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#29 0x00007f885dd07e40 call_init ./csu/../csu/libc-start.c:128:20
#30 0x00007f885dd07e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#31 0x000000000040e3b5 _start (/usr/lib/llvm-14/bin/clang+0x40e3b5)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg:

Pointer errors with VNImageRequestHandler attempting OCR

I've tried to implement OCR exactly as outlined on the Apple website (https://developer.apple.com/documentation/vision/recognizing_text_in_images), but I get a range of pointer errors when I attempt to perform the OCR. Error has been labelled in Xcode with Thread 1: EXC_BAD_ACCESS (code=1, address=0x17dfe3ff0) or Thread 1: De-allocation of unallocated memory.
My questions are this:
Why am I getting a pointer error from within one of Apple's own packages? Have I got something wrong in the setup that I've missed?
(Minor point) Why is this crashing my app, rather than being caught gracefully?
I think it might be something do with the UIImage being de-allocated before the VNImageRequestHandler gets to it? I have a separate camera framework that I use to take and crop the photograph and return the image, so maybe the image is being de-allocated or is being considered out of scope? I've seen this error before and it just disappeared overnight, but I'd rather not just cross my fingers and hope it goes away!
EDIT: Following a suggestion in the comments, I turned off the Address Sanitizer, and it seems to work again. Not marking this as solved, as I'd prefer my code not to break when I turn on debugging tools...
#available(iOS 13.0, *)
class func recogniseText(inImage: UIImage, completionHandler: #escaping (_ recognisedText: String?) -> Void){
guard let cgImage = inImage.cgImage else{
return completionHandler(nil)
}
let requestHandler = VNImageRequestHandler(cgImage: cgImage)
let ocrRequest = VNRecognizeTextRequest { (request, error) in
guard let observations = request.results as? [VNRecognizedTextObservation] else{
return completionHandler(nil)
}
let recognizedStrings = observations.compactMap { observation in
// Return the string of the top VNRecognizedText instance.
observation.topCandidates(1).first?.string
}
completionHandler(recognizedStrings.joined(separator: "\n"))
}
ocrRequest.recognitionLevel = .accurate
ocrRequest.recognitionLanguages = ["en-GB"]
ocrRequest.usesLanguageCorrection = false
do {
try requestHandler.perform([ocrRequest]) // Error is thrown here
} catch {
completionHandler(nil)
}
}
Log is as follows:
=================================================================
==1979==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00017b400000 in thread T0
#0 0x1033df438 in wrap_free+0x8c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438)
#1 0x195b3d0f4 in <redacted>+0x3c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xf0f4)
#2 0x195b40470 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0x12470)
#3 0x195b380b0 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xa0b0)
#4 0x199aebf0c in <redacted>+0x6c (/usr/lib/libobjc.A.dylib:arm64+0x6f0c)
#5 0x199ae8f04 in objc_destructInstance+0x54 (/usr/lib/libobjc.A.dylib:arm64+0x3f04)
#6 0x199af1db8 in _objc_rootDealloc+0x30 (/usr/lib/libobjc.A.dylib:arm64+0xcdb8)
#7 0x199aeb584 in <redacted>+0xc0 (/usr/lib/libobjc.A.dylib:arm64+0x6584)
#8 0x199ae7dec in objc_autoreleasePoolPop+0xc8 (/usr/lib/libobjc.A.dylib:arm64+0x2dec)
#9 0x1a47bfb80 in <redacted>+0x100 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4b80)
#10 0x1a47bfa3c in <redacted>+0x30 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4a3c)
#11 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
#12 0x1a482d6dc in <redacted>+0x28 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x726dc)
#13 0x10444d600 in _dispatch_block_sync_invoke+0x68 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x9600)
#14 0x104449f90 in _dispatch_client_callout+0xc (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x5f90)
#15 0x104459634 in _dispatch_lane_barrier_sync_invoke_and_complete+0x74 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x15634)
#16 0x10444eb18 in _dispatch_sync_block_with_privdata+0x188 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0xab18)
#17 0x1a47c4eac in <redacted>+0x19c (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9eac)
#18 0x1a499251c in <redacted>+0x220 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x1d751c)
#19 0x1a47bd79c in <redacted>+0x2c0 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x279c)
#20 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
#21 0x1a47c4514 in <redacted>+0x200 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9514)
#22 0x1a47c2a9c in <redacted>+0x1b4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7a9c)
#23 0x1a47c2878 in <redacted>+0xb4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7878)
#24 0x100fd69b4 in static ---.---.recogniseText(inImage: __C.UIImage, completionHandler: (Swift.Optional<Swift.String>) -> ()) -> ()+0x890 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1001ea9b4)
#25 0x100ee3458 in ---.---View.---Controller(_: ---.---Controller, didFinishScanningWithResults: ---.ImageScannerResults) -> ()+0x4b4 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000f7458)
#26 0x100ee68bc in protocol witness for ---.ImageScannerControllerDelegate.imageScannerController(_: ---.ImageScannerController, didFinishScanningWithResults: ---.ImageScannerResults) -> () in conformance ---.IdentityGetStartedView : ---.ImageScannerControllerDelegate in ---+0x8 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000fa8bc)
#27 0x103f0deb0 in ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x49c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/---:arm64+0x4deb0)
#28 0x103f0df40 in #objc ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x20 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/---:arm64+0x4df40)
#29 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
#30 0x18537386c in <redacted>+0xac (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x75b86c)
#31 0x18535e6d0 in <redacted>+0x20 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x7466d0)
#32 0x18535e584 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x746584)
#33 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
#34 0x1851d67d4 in <redacted>+0x78 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x5be7d4)
#35 0x184f69d70 in <redacted>+0x158 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351d70)
#36 0x184f69dc0 in <redacted>+0x1a8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351dc0)
#37 0x18527b2e4 in <redacted>+0x210 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x6632e4)
#38 0x184d7bbf8 in <redacted>+0x4c8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x163bf8)
#39 0x184dabc54 in <redacted>+0x1124 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x193c54)
#40 0x184f4ee70 in <redacted>+0x37c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x336e70)
#41 0x184d8070c in <redacted>+0x1fb8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x16870c)
#42 0x184d75658 in <redacted>+0x1a58 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x15d658)
#43 0x184d7a9e8 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x1629e8)
#44 0x18296620c in <redacted>+0x14 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xb220c)
#45 0x182976234 in <redacted>+0xc8 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xc2234)
#46 0x1828b95d4 in <redacted>+0xfc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x55d4)
#47 0x1828bea04 in <redacted>+0x2fc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xaa04)
#48 0x1828d1d78 in CFRunLoopRunSpecific+0x238 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x1dd78)
#49 0x19cb4699c in GSEventRunModal+0x9c (/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices:arm64+0x199c)
#50 0x185104058 in <redacted>+0x434 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x4ec058)
#51 0x184e99cdc in UIApplicationMain+0x7e8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x281cdc)
#52 0x101212988 in main+0x3c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x100426988)
#53 0x102f6018c (/usr/lib/dyld:arm64+0x1818c)
Address 0x00017b400000 is a wild pointer.
SUMMARY: AddressSanitizer: bad-free (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438) in wrap_free+0x8c
2021-12-01 15:31:56.039013+0000 ---[1979:545450] =================================================================
2021-12-01 15:31:56.039144+0000 ---[1979:545450] ==1979==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00017b400000 in thread T0
2021-12-01 15:31:56.039222+0000 ---[1979:545450] #0 0x1033df438 in wrap_free+0x8c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438)
2021-12-01 15:31:56.039287+0000 ---[1979:545450] #1 0x195b3d0f4 in <redacted>+0x3c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xf0f4)
2021-12-01 15:31:56.039350+0000 ---[1979:545450] #2 0x195b40470 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0x12470)
2021-12-01 15:31:56.039410+0000 ---[1979:545450] #3 0x195b380b0 in <redacted>+0x4c (/System/Library/Frameworks/CoreML.framework/CoreML:arm64+0xa0b0)
2021-12-01 15:31:56.039472+0000 ---[1979:545450] #4 0x199aebf0c in <redacted>+0x6c (/usr/lib/libobjc.A.dylib:arm64+0x6f0c)
2021-12-01 15:31:56.039539+0000 ---[1979:545450] #5 0x199ae8f04 in objc_destructInstance+0x54 (/usr/lib/libobjc.A.dylib:arm64+0x3f04)
2021-12-01 15:31:56.040035+0000 ---[1979:545450] #6 0x199af1db8 in _objc_rootDealloc+0x30 (/usr/lib/libobjc.A.dylib:arm64+0xcdb8)
2021-12-01 15:31:56.040115+0000 ---[1979:545450] #7 0x199aeb584 in <redacted>+0xc0 (/usr/lib/libobjc.A.dylib:arm64+0x6584)
2021-12-01 15:31:56.040179+0000 ---[1979:545450] #8 0x199ae7dec in objc_autoreleasePoolPop+0xc8 (/usr/lib/libobjc.A.dylib:arm64+0x2dec)
2021-12-01 15:31:56.040240+0000 ---[1979:545450] #9 0x1a47bfb80 in <redacted>+0x100 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4b80)
2021-12-01 15:31:56.040305+0000 ---[1979:545450] #10 0x1a47bfa3c in <redacted>+0x30 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x4a3c)
2021-12-01 15:31:56.040366+0000 ---[1979:545450] #11 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
2021-12-01 15:31:56.040429+0000 ---[1979:545450] #12 0x1a482d6dc in <redacted>+0x28 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x726dc)
2021-12-01 15:31:56.040575+0000 ---[1979:545450] #13 0x10444d600 in _dispatch_block_sync_invoke+0x68 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x9600)
2021-12-01 15:31:56.040639+0000 ---[1979:545450] #14 0x104449f90 in _dispatch_client_callout+0xc (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x5f90)
2021-12-01 15:31:56.040704+0000 ---[1979:545450] #15 0x104459634 in _dispatch_lane_barrier_sync_invoke_and_complete+0x74 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0x15634)
2021-12-01 15:31:56.041072+0000 ---[1979:545450] #16 0x10444eb18 in _dispatch_sync_block_with_privdata+0x188 (/usr/lib/system/introspection/libdispatch.dylib:arm64+0xab18)
2021-12-01 15:31:56.041140+0000 ---[1979:545450] #17 0x1a47c4eac in <redacted>+0x19c (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9eac)
2021-12-01 15:31:56.041203+0000 ---[1979:545450] #18 0x1a499251c in <redacted>+0x220 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x1d751c)
2021-12-01 15:31:56.041434+0000 ---[1979:545450] #19 0x1a47bd79c in <redacted>+0x2c0 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x279c)
2021-12-01 15:31:56.041497+0000 ---[1979:545450] #20 0x1a47c8d28 in <redacted>+0x44 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0xdd28)
2021-12-01 15:31:56.041555+0000 ---[1979:545450] #21 0x1a47c4514 in <redacted>+0x200 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x9514)
2021-12-01 15:31:56.041636+0000 ---[1979:545450] #22 0x1a47c2a9c in <redacted>+0x1b4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7a9c)
2021-12-01 15:31:56.041699+0000 ---[1979:545450] #23 0x1a47c2878 in <redacted>+0xb4 (/System/Library/Frameworks/Vision.framework/Vision:arm64+0x7878)
2021-12-01 15:31:56.041758+0000 ---[1979:545450] #24 0x100fd69b4 in static ---.IdentityDocumentController.recogniseText(inImage: __C.UIImage, completionHandler: (Swift.Optional<Swift.String>) -> ()) -> ()+0x890 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1001ea9b4)
2021-12-01 15:31:56.041924+0000 ---[1979:545450] #25 0x100ee3458 in ---.IdentityGetStartedView.imageScannerController(_: ---.ImageScannerController, didFinishScanningWithResults: ---.ImageScannerResults) -> ()+0x4b4 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000f7458)
2021-12-01 15:31:56.041993+0000 ---[1979:545450] #26 0x100ee68bc in protocol witness for ---.ImageScannerControllerDelegate.imageScannerController(_: ---.ImageScannerController, didFinishScanningWithResults: ---.ImageScannerResults) -> () in conformance ---.IdentityGetStartedView : ---.ImageScannerControllerDelegate in ---+0x8 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x1000fa8bc)
2021-12-01 15:31:56.042248+0000 ---[1979:545450] #27 0x103f0deb0 in ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x49c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/---:arm64+0x4deb0)
2021-12-01 15:31:56.042315+0000 ---[1979:545450] #28 0x103f0df40 in #objc ---.ReviewViewController.(finishScan in _9E959B31AA30B2E6A6CE4785C0F01E54)() -> ()+0x20 (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/---.framework/PIOScanningKit:arm64+0x4df40)
2021-12-01 15:31:56.042379+0000 ---[1979:545450] #29 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
2021-12-01 15:31:56.042761+0000 ---[1979:545450] #30 0x18537386c in <redacted>+0xac (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x75b86c)
2021-12-01 15:31:56.042861+0000 ---[1979:545450] #31 0x18535e6d0 in <redacted>+0x20 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x7466d0)
2021-12-01 15:31:56.042927+0000 ---[1979:545450] #32 0x18535e584 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x746584)
2021-12-01 15:31:56.042989+0000 ---[1979:545450] #33 0x1850b56a4 in <redacted>+0x5c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x49d6a4)
2021-12-01 15:31:56.043052+0000 ---[1979:545450] #34 0x1851d67d4 in <redacted>+0x78 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x5be7d4)
2021-12-01 15:31:56.043113+0000 ---[1979:545450] #35 0x184f69d70 in <redacted>+0x158 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351d70)
2021-12-01 15:31:56.043796+0000 ---[1979:545450] #36 0x184f69dc0 in <redacted>+0x1a8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x351dc0)
2021-12-01 15:31:56.043858+0000 ---[1979:545450] #37 0x18527b2e4 in <redacted>+0x210 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x6632e4)
2021-12-01 15:31:56.043916+0000 ---[1979:545450] #38 0x184d7bbf8 in <redacted>+0x4c8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x163bf8)
2021-12-01 15:31:56.043980+0000 ---[1979:545450] #39 0x184dabc54 in <redacted>+0x1124 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x193c54)
2021-12-01 15:31:56.044110+0000 ---[1979:545450] #40 0x184f4ee70 in <redacted>+0x37c (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x336e70)
2021-12-01 15:31:56.044359+0000 ---[1979:545450] #41 0x184d8070c in <redacted>+0x1fb8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x16870c)
2021-12-01 15:31:56.044800+0000 ---[1979:545450] #42 0x184d75658 in <redacted>+0x1a58 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x15d658)
2021-12-01 15:31:56.045033+0000 ---[1979:545450] #43 0x184d7a9e8 in <redacted>+0xa4 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x1629e8)
2021-12-01 15:31:56.045255+0000 ---[1979:545450] #44 0x18296620c in <redacted>+0x14 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xb220c)
2021-12-01 15:31:56.045481+0000 ---[1979:545450] #45 0x182976234 in <redacted>+0xc8 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xc2234)
2021-12-01 15:31:56.046587+0000 ---[1979:545450] #46 0x1828b95d4 in <redacted>+0xfc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x55d4)
2021-12-01 15:31:56.046847+0000 ---[1979:545450] #47 0x1828bea04 in <redacted>+0x2fc (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0xaa04)
2021-12-01 15:31:56.047586+0000 ---[1979:545450] #48 0x1828d1d78 in CFRunLoopRunSpecific+0x238 (/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation:arm64+0x1dd78)
2021-12-01 15:31:56.047851+0000 ---[1979:545450] #49 0x19cb4699c in GSEventRunModal+0x9c (/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices:arm64+0x199c)
2021-12-01 15:31:56.048791+0000 ---[1979:545450] #50 0x185104058 in <redacted>+0x434 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x4ec058)
2021-12-01 15:31:56.049650+0000 ---[1979:545450] #51 0x184e99cdc in UIApplicationMain+0x7e8 (/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:arm64+0x281cdc)
2021-12-01 15:31:56.049949+0000 ---[1979:545450] #52 0x101212988 in main+0x3c (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/---:arm64+0x100426988)
2021-12-01 15:31:56.052728+0000 ---[1979:545450] #53 0x102f6018c (/usr/lib/dyld:arm64+0x1818c)
2021-12-01 15:31:56.053015+0000 ---[1979:545450]
2021-12-01 15:31:56.053260+0000 ---[1979:545450] Address 0x00017b400000 is a wild pointer.
2021-12-01 15:31:56.053516+0000 ---[1979:545450] SUMMARY: AddressSanitizer: bad-free (/private/var/containers/Bundle/Application/A60B9200-585C-47ED-B991-C4EFD9CDF577/---.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x3f438) in wrap_free+0x8c
==1979==ABORTING
EDITED: This configuration of the scheme seems to work for me perfectly. 'The Guard Malloc' and 'Malloc Guard Edges' options seem to stop the problem of deallocating unallocated memory by VNImageRequestHandler.

type '(PlatformException) => void' is not a subtype of type '(Object) => FutureOr<dynamic> Flutter

I am using Event Channels in Flutter to return beacon data from Native SDK to Flutter. This was working fine until a recent Flutter upgrade.Now, I am getting the following error.
type '(PlatformException) => void' is not a subtype of type '(Object) => FutureOr<dynamic>
with the following stack trace:
#0 _registerErrorHandler (dart:async/async_error.dart:22:60)
#1 _BufferingStreamSubscription.onError (dart:async/stream_impl.dart:146:16)
#2 new _BufferingStreamSubscription (dart:async/stream_impl.dart:113:10)
#3 new _ControllerSubscription (dart:async/stream_controller.dart)
#4 new _BroadcastSubscription (dart:async/broadcast_stream_controller.dart)
#5 _BroadcastStreamController._subscribe (dart:async/broadcast_stream_controller.dart:212:46)
#6 _ControllerStream._createSubscription (dart:async/stream_controller.dart:817:19)
#7 _StreamImpl.listen (dart:async/stream_impl.dart:466:9)
#8 _MyHomePageState.initPlatformState.<anonymous closure>.<anonymous closure> (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:95:43)
#9 _RootZone.runUnary (dart:async/zone.dart:1381:54)
#10 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#11 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
#12 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
#13 Future._complete (dart:async/future_impl.dart:467:7)
#14 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#15 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
<asynchronous suspension>
#16 _MyHomePageState.initPlatformState.<anonymous closure> (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:89:24)
<asynchronous suspension>
#17 _RootZone.runUnary (dart:async/zone.dart:1381:54)
#18 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#19 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
#20 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
#21 Future._complete (dart:async/future_impl.dart:467:7)
#22 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#23 User_Profile.getUser (package:flutter_poc/Models/User.dart)
<asynchronous suspension>
#24 _MyHomePageState.initPlatformState (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:69:24)
<asynchronous suspension>
#25 _MyHomePageState.initState (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:52:5)
#26 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
#27 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
#28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
#29 Element.updateChild
This is my EventChannel implementation:
static const platform = const MethodChannel('samples.flutter.io/initialiseRanging');
static const stream =
const EventChannel('samples.flutter.io/ranging');
try {
await platform.invokeMethod('initialiseRanging').then((result){
print(result);
setState(() {
_currentValue = result;
});
stream.receiveBroadcastStream().listen(_onEvent, onError: _onError);
});
} on PlatformException catch (e) {
print( "{e.message}");
}
This is how the _onEvent and _onError functions are implemented.
void _onEvent(Object event) {
setState(() {
_currentValue = event.toString();
});
print(event);
}
void _onError(PlatformException error) {
print(error);
}
Any idea on why this could possible happen?
void _onError(PlatformException error) {
should be
void _onError(Object error) {
Even when you are only interested in PlatformException or even when this is the only exception that happened so far, doesn't mean there can't be others. The expected handler function needs to match the parameter type, instead of only the exceptions you expect.

Z3 c code works for some loop count numbers and not for others

I have written a Z3 program (starting from test_capi.c) that loops on some number "parameter" and adds constraints for each loop cycle, that are dependent on the previous loop's constraints. The idea is that each cycle 2 items a,d are selected which would be either the same old a,d or new a,d picked by pointer_a, pointer_d from ordered lists u_a, u_d.
The code works for some loop counts and not for others (gives sat versus a segmentation fault). More strange, the numbers of the loop counts for which the code works changes when changing the code. So the code below works and is SAT (I already picked n_ABCD=check3 ), but it gives the result only for "parameter" from 2 up to 10, except for 6, and for parameter=8, 16, 32 and could be some other numbers, but I tried those at least; it didn't work for 31, 33, 64, 128 and 512. When I split the loop into 2 loops one for the pointer_a[] & pointer_d[] constraints, and the other for the check_v manipulation the code works for "parameter" up to 9, and then for 12, 14, 17 and 27 & I've not been lucky with other bigger numbers. The goal was to run it up to parameter=1024 or even more.
Any explanation of why could the code be running only for some numbers and not for others? Is it related to how the selection of the arbitrary terms being evaluated works? (make_var_feasible, update_and_pivot ... as in the gdb trace more below)
char cated_string[20];
for(int i = 0; i< parameter; i++){
sprintf(cated_string,"%s%d%s", "pointer_d[", i, "]");
pointer_d[i] = mk_var(ctx, cated_string , bv32_sort);
sprintf(cated_string,"%s%d%s", "pointer_a[", i, "]");
pointer_a[i] = mk_var(ctx, cated_string , bv32_sort);
}
u_d_ast = mk_var(ctx, "u_d_ast", array_sort);
u_a_ast = mk_var(ctx, "u_a_ast", array_sort);
for (unsigned int i = 0; i < parameter; i++) {index = Z3_mk_unsigned_int(ctx, i, bv32_sort);
u_d_ast = Z3_mk_store(ctx, u_d_ast, index, u_d[i]);
u_a_ast = Z3_mk_store(ctx, u_a_ast, index, u_a[i]);
}
Z3_solver_assert(ctx, s, Z3_mk_eq(ctx, pointer_d[0], n_zero) );
Z3_solver_assert(ctx, s, Z3_mk_eq(ctx, pointer_a[0], n_zero) );
a_v = mk_var(ctx, "a_v", array_sort);
d_v = mk_var(ctx, "d_v", array_sort);
check_v = mk_var(ctx, "check_v" , array_sort);
check_v = Z3_mk_store(ctx, check_v, n_zero, n_zero );
a_v = Z3_mk_store(ctx, a_v, n_zero, Z3_mk_select(ctx, u_a_ast, n_zero) );
d_v = Z3_mk_store(ctx, d_v, n_zero, Z3_mk_select(ctx, u_d_ast, n_zero) );
for (int i = 1; i< parameter; i++){
ind = Z3_mk_unsigned_int(ctx, i, bv32_sort);
ind_1 = Z3_mk_unsigned_int(ctx, i-1, bv32_sort);
check_old = Z3_mk_select(ctx, check_v , ind_1 );
d_v = Z3_mk_store(ctx, d_v, ind, Z3_mk_select(ctx, u_d_ast, pointer_d[i]) );
d_new = Z3_mk_select(ctx, d_v , ind );
pointer_d_plus_1 = Z3_mk_bvadd(ctx, pointer_d[i-1], n_one);
condition_d_pointer1[i] = Z3_mk_ge(ctx, Z3_mk_bv2int(ctx, pointer_d[i], false), Z3_mk_bv2int(ctx, pointer_d[i-1], false) );
condition_d_pointer2[i] = Z3_mk_le(ctx, Z3_mk_bv2int(ctx, pointer_d[i], false), Z3_mk_bv2int(ctx, pointer_d_plus_1, false) );
Z3_solver_assert(ctx, s, condition_d_pointer1[i]);
Z3_solver_assert(ctx, s, condition_d_pointer2[i]);
a_v = Z3_mk_store(ctx, a_v, ind, Z3_mk_select(ctx, u_a_ast, pointer_a[i]) );
a_new = Z3_mk_select(ctx, a_v , ind );
pointer_a_plus_1 = Z3_mk_bvadd(ctx, pointer_a[i-1], n_one);
condition_a_pointer1[i] = Z3_mk_ge(ctx, Z3_mk_bv2int(ctx, pointer_a[i], false), Z3_mk_bv2int(ctx, pointer_a[i-1], false) );
condition_a_pointer2[i] = Z3_mk_le(ctx, Z3_mk_bv2int(ctx, pointer_a[i], false), Z3_mk_bv2int(ctx, pointer_a_plus_1, false) );
Z3_solver_assert(ctx, s, condition_a_pointer1[i]);
Z3_solver_assert(ctx, s, condition_a_pointer2[i]);
d_xor_a = Z3_mk_bvxor(ctx, d_new , a_new);
check_new = Z3_mk_bvxor(ctx, check_old, d_xor_a);
check_v = Z3_mk_store(ctx, check_v, ind, check_new);
}
check3 = Z3_mk_select(ctx, check_v , n_position );
eq = Z3_mk_eq(ctx, n_ABCD, check3);
Z3_solver_assert(ctx, s, eq );
check(ctx, s, Z3_L_TRUE);
Trying to run a failing instance with gdb, it gives the following message:
Program received signal SIGSEGV, Segmentation fault.
0x00001blaab9fff68 in mpn_manager::div_normalize(unsigned int const*, unsigned long, unsigned int const*, unsigned long, mpn_manager::mpn_sbuffer&, mpn_manager::mpn_sbuffer&) const () from /lib/libz3.so
(gdb) backtrace
#0 0x00001blaab9ffd68 in mpn_manager::div_normalize(unsigned int const*, unsigned long, unsigned int const*, unsigned long, mpn_manager::mpn_sbuffer&, mpn_manager::mpn_sbuffer&) const () from /lib/libz3.so
#1 0x00001blaab9ffaf9 in mpn_manager::div(unsigned int const*, unsigned long, unsigned int const*, unsigned long, unsigned int*, unsigned int*) () from /lib/libz3.so
#2 0x00001blaab9e387e in void mpz_manager<true>::quot_rem_core<1>(mpz const&, mpz const&, mpz&, mpz&) () from /lib/libz3.so
#3 0x00001blaab9e4216 in mpz_manager<true>::rem(mpz const&, mpz const&, mpz&) () from /lib/libz3.so
#4 0x00001blaab9e4b71 in mpz_manager<true>::gcd(mpz const&, mpz const&, mpz&) () from /lib/libz3.so
#5 0x00001blaabdef04f in mpq_manager<true>::div(mpq const&, mpq const&, mpq&) () from /lib/libz3.so
#6 0x00001blaab139a0e in smt::theory_arith<smt::mi_ext>::update_and_pivot(int, int, rational const&, inf_rational const&) () from /lib/libz3.so
#7 0x00001blaab13a996 in smt::theory_arith<smt::mi_ext>::make_var_feasible(int) () from /lib/libz3.so
#8 0x00001blaab135aca in smt::theory_arith<smt::mi_ext>::make_feasible() () from /lib/libz3.so
#9 0x00001blaab136b13 in smt::theory_arith<smt::mi_ext>::propagate_core() () from /lib/libz3.so
#10 0x00001blaab22d9ad in smt::context::propagate() () from /lib/libz3.so
#11 0x00001blaab2328c0 in smt::context::bounded_search() () from /lib/libz3.so
#12 0x00001blaab231cd8 in smt::context::search() () from /lib/libz3.so
#13 0x00001blaab231b72 in smt::context::setup_and_check(bool) () from /lib/libz3.so
#14 0x00001blaaa10143f in smt_tactic::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) () from /lib/libz3.so
#15 0x00001blaab665115 in and_then_tactical::operator()(ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) () from /lib/libz3.so
#16 0x00001blaab65a333 in exec(tactic&, ref<goal> const&, sref_buffer<goal, 16u>&, ref<model_converter>&, ref<proof_converter>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&) () from /lib/libz3.so
#17 0x00001blaab65a5ad in check_sat(tactic&, ref<goal>&, ref<model>&, obj_ref<app, ast_manager>&, obj_ref<dependency_manager<ast_manager::expr_dependency_config>::dependency, ast_manager>&, std::string&) () from /lib/libz3.so
#18 0x00001blaab539703 in tactic2solver::check_sat_core(unsigned int, expr* const*) () from /lib/libz3.so
#19 0x00001blaab54208b in solver_na2as::check_sat(unsigned int, expr* const*) () from /lib/libz3.so
#20 0x00001blaab53d519 in combined_solver::check_sat(unsigned int, expr* const*) () from /lib/libz3.so
#21 0x00001blaaad73f8e in Z3_solver_check () from /lib/libz3.so
#22 0x0000000000402ce4 in check (ctx=0x622f48, s=0x66d948, expected_result=Z3_L_TRUE) at example.c:210
#23 0x0000000000405830 in main () at example.c:1129
As in here: Check overflow with Z3
Seems the problem is due to Z3_mk_bv2int corruption. When I used mk_eq and then mk_or instead of these less-than/greater-than than or equal, (or using the bv version of gte, lte; i.e. Z3_mk_bvuge & Z3_mk_bvule) it works fine for all numbers.

Resources