Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

InfiniteCanvas Heap Corruption #3178

Closed

Description

@vborovikov

Describe the bug

A normal work with InfiniteCanvas control causes a heap corruption exception.

0xC0000374: A heap has been corrupted

Steps to Reproduce

Steps to reproduce the behavior:

  1. Install Windows Community toolkit Sample App
  2. Open InfiniteCanvas page
  3. Draw some ink with default settings
  4. Scroll and zoom the canvas

The app will crash. Same will happen when using the control outside the sample app.

Expected behavior

The app/control should continue to work.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

NuGet Package(s): 

Package Version(s): 

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ x] May 2019 Update (18362)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [ ] Insider Build (xxxxx)

Device form factor:
- [ x] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [ x] 2019 (version: ) 
- [ ] 2019 Preview (version: )

Additional context

Event Log entry

Faulting application name: Microsoft.Toolkit.Uwp.SampleApp.exe, version: 0.0.0.0, time stamp: 0x5dca712c
Faulting module name: ntdll.dll, version: 10.0.18362.719, time stamp: 0x64d10ee0
Exception code: 0xc0000374
Fault offset: 0x00000000000f92a9
Faulting process id: 0x120
Faulting application start time: 0x01d5ff960bcc9fc4
Faulting application path: C:\Program Files\WindowsApps\Microsoft.UWPCommunityToolkitSampleApp_6.0.0.0_x64__8wekyb3d8bbwe\Microsoft.Toolkit.Uwp.SampleApp.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: c77fa18c-e1a7-4d57-b140-d62a8b462f4a
Faulting package full name: Microsoft.UWPCommunityToolkitSampleApp_6.0.0.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App

Sample call stack

ntdll.dll!RtlReportCriticalFailure()   Unknown
ntdll.dll!RtlpHeapHandleError()    Unknown
ntdll.dll!RtlpHpHeapHandleError()  Unknown
ntdll.dll!RtlpLogHeapFailure() Unknown
ntdll.dll!RtlpHpLfhSubsegmentFreeBlock()    Unknown
ntdll.dll!RtlpFreeHeapInternal()    Unknown
ntdll.dll!RtlpHpFreeWithExceptionProtection()  Unknown
ntdll.dll!RtlFreeHeap() Unknown
msvcrt.dll!free()  Unknown
Windows.UI.Input.Inking.dll!std::_Tree<std::_Tmap_traits<Windows::UI::Input::Inking::IInkRenderableStroke *,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo,std::less<Windows::UI::Input::Inking::IInkRenderableStroke *>,std::allocator<std::pair<Windows::UI::Input::Inking::IInkRenderableStroke * const,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo>>,0>>::erase(std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<Windows::UI::Input::Inking::IInkRenderableStroke * const,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo>>>> _Where) Line 1500  C++
Windows.UI.Input.Inking.dll!std::_Tree<std::_Tmap_traits<Windows::UI::Input::Inking::IInkRenderableStroke *,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo,std::less<Windows::UI::Input::Inking::IInkRenderableStroke *>,std::allocator<std::pair<Windows::UI::Input::Inking::IInkRenderableStroke * const,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo>>,0>>::erase(std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<Windows::UI::Input::Inking::IInkRenderableStroke * const,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo>>>> _First, std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<Windows::UI::Input::Inking::IInkRenderableStroke * const,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo>>>> _Last) Line 1517   C++
Windows.UI.Input.Inking.dll!std::_Tree<std::_Tmap_traits<Windows::UI::Input::Inking::IInkRenderableStroke *,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo,std::less<Windows::UI::Input::Inking::IInkRenderableStroke *>,std::allocator<std::pair<Windows::UI::Input::Inking::IInkRenderableStroke * const,SurfaceBaseRender<SurfaceDefaultRender>::StrokeInfo>>,0>>::erase(Windows::UI::Input::Inking::IInkRenderableStroke * const & _Keyval) Line 1530  C++
Windows.UI.Input.Inking.dll!SurfaceBaseRender<SurfaceDefaultRender>::OnStrokeModified(Windows::UI::Input::Inking::IInkRenderableStroke * stroke, Windows::UI::Input::Inking::RenderableStrokeChange change) Line 127    C++
[Inline Frame] Windows.UI.Input.Inking.dll!Microsoft::WRL::Callback::__l2::<lambda_1e0ee65a6e77c55bcc6e8804ffe2811b>::operator()(Windows::UI::Input::Inking::Core::ICoreIncrementalInkStroke * &&) Line 335 C++
Windows.UI.Input.Inking.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl Windows::Foundation::ITypedEventHandler_impl<Windows::Foundation::Internal::AggregateType<Windows::UI::Input::Inking::Core::CoreIncrementalInkStroke *,Windows::UI::Input::Inking::Core::ICoreIncrementalInkStroke *>,IInspectable *>::*)(Windows::UI::Input::Inking::Core::ICoreIncrementalInkStroke *,IInspectable *)>::DelegateInvokeHelper<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::Core::CoreIncrementalInkStroke *,IInspectable *>,<lambda_1e0ee65a6e77c55bcc6e8804ffe2811b>,-1,Windows::UI::Input::Inking::Core::ICoreIncrementalInkStroke *,IInspectable *>::Invoke(Windows::UI::Input::Inking::Core::ICoreIncrementalInkStroke * <args_0>, IInspectable * <args_1>) Line 245   C++
[Inline Frame] Windows.UI.Input.Inking.dll!Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::IInkRenderableStroke *,enum Windows::UI::Input::Inking::RenderableStrokeChange>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll::__l2::<lambda_d630d8126d99d760408ed52fc0792ed8>::operator()(Microsoft::WRL::ComPtr<IUnknown> &) Line 820  C++
Windows.UI.Input.Inking.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<<lambda_d630d8126d99d760408ed52fc0792ed8>,Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::IInkRenderableStroke *,enum Windows::UI::Input::Inking::RenderableStrokeChange>>(Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::IInkRenderableStroke *,enum Windows::UI::Input::Inking::RenderableStrokeChange>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll::__l2::<lambda_d630d8126d99d760408ed52fc0792ed8> invokeOne, Microsoft::WRL::Details::EventTargetArray * targetArray, Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::IInkRenderableStroke *,enum Windows::UI::Input::Inking::RenderableStrokeChange>,Microsoft::WRL::InvokeModeOptions<-2>> * pEvent) Line 119   C++
[Inline Frame] Windows.UI.Input.Inking.dll!Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::IInkRenderableStroke *,enum Windows::UI::Input::Inking::RenderableStrokeChange>,Microsoft::WRL::InvokeModeOptions<-2>>::DoInvoke(Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::IInkRenderableStroke *,enum Windows::UI::Input::Inking::RenderableStrokeChange>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll::__l2::<lambda_d630d8126d99d760408ed52fc0792ed8>) Line 810    C++
[Inline Frame] Windows.UI.Input.Inking.dll!Microsoft::WRL::EventSource<Windows::Foundation::ITypedEventHandler<Windows::UI::Input::Inking::IInkRenderableStroke *,enum Windows::UI::Input::Inking::RenderableStrokeChange>,Microsoft::WRL::InvokeModeOptions<-2>>::InvokeAll(Windows::UI::Input::Inking::CInkStroke * <args_0>, Windows::UI::Input::Inking::RenderableStrokeChange <args_1>) Line 820   C++
Windows.UI.Input.Inking.dll!Windows::UI::Input::Inking::CInkStroke::RaiseStrokeModifiedEvent(Windows::UI::Input::Inking::RenderableStrokeChange value) Line 2596    C++
[Inline Frame] Windows.UI.Input.Inking.dll!Windows::UI::Input::Inking::CInkStroke::{dtor}() Line 72 C++
Windows.UI.Input.Inking.dll!Windows::UI::Input::Inking::CInkStroke::`scalar deleting destructor'(unsigned int)  C++
Windows.UI.Input.Inking.dll!Microsoft::WRL::Details::RuntimeClassImpl<Microsoft::WRL::RuntimeClassFlags<3>,1,1,0,Windows::UI::Input::Inking::IInkStroke,Windows::UI::Input::Inking::IInkStroke2,Windows::UI::Input::Inking::IInkStroke3,Windows::UI::Input::Inking::IInkRenderableStroke,Windows::UI::Input::Internal::Inking::IInkStrokeInternal,IAgileObject,Microsoft::WRL::FtmBase>::Release() Line 2010    C++
kernel32.dll!BaseThreadInitThunk() Unknown
ntdll.dll!RtlUserThreadStart() Unknown

Activity

  1. added
    bug 🐛An unexpected issue that highlights incorrect behavior
    on Mar 21, 2020
  2. Kyaa-dost commented on Mar 21, 2020

    @Kyaa-dost
    Contributor

    @vborovikov I am not able to reproduce this based on the steps mentioned above. Can you please screen record this so we can see the process you are following?

  3. vborovikov commented on Mar 22, 2020

    @vborovikov
    Author

    Recorded the steps using Steps Recorder app. The record was stopped when the app has crashed.

    wintk_crash.zip

  4. Kyaa-dost commented on Mar 23, 2020

    @Kyaa-dost
    Contributor

    @vborovikov I am not seeing anything in this zip folder. It seems to be a list of empty screenshots.

    image

  5. vborovikov commented on Mar 25, 2020

    @vborovikov
    Author

    https://youtu.be/xJI1g_u_50A

    Notice in the end the ink gets blurry, it's the moment the app crashes.

  6. Kyaa-dost commented on Apr 8, 2020

    @Kyaa-dost
    Contributor

    Thanks for showing the error @vborovikov. @deanchalk will you be able to look into this?

  7. added a commit that references this issue on Apr 9, 2020
  8. deanchalk commented on Apr 9, 2020

    @deanchalk

    I have created a pull request #3228
    I couldnt recreate the heap corruption issue, but I did manage to crash the app consistently using the pan/zoom features. The PR isnt an ideal fix, but it seems to be the best we can do with the current implementation. of the control.
    Let me know what you think

  9. Kyaa-dost commented on Apr 9, 2020

    @Kyaa-dost
    Contributor

    Thanks @deanchalk will check it out.

    @vborovikov what do you think?

  10. vborovikov commented on Apr 12, 2020

    @vborovikov
    Author

    I've managed to eliminate heap corruption exceptions by refactoring InkDrawable.

    It create copies of InkStroke objects on each draw request in order to make ink point coordinates relative to the current drawing session coordinate system. I changed the drawing session coordinate system to be global so no changes to InkStroke points is required.

    // Update the existing translation to account for the viewPort rect (so the resulting
    // drawing session has the same coordinate system relative to the entire
    // canvas, rather than relative to the viewPort rect).
    drawingSession.Transform = Matrix3x2.CreateTranslation(
            drawingSession.Transform.Translation.X - Convert.ToSingle(viewPort.X),
            drawingSession.Transform.Translation.Y - Convert.ToSingle(viewPort.Y));

    and InkDrawable simply calls DrawInk with the original collection of InkStroke objects:

    public void Draw(CanvasDrawingSession drawingSession, Rect sessionBounds)
    {
        drawingSession.DrawInk(this.Strokes);
    }
  11. added a commit that references this issue on May 26, 2020
  12. added this to the 6.1 milestone on May 28, 2020
  13. ghost locked as resolved and limited conversation to collaborators on Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions