Qt World Summit: Submit your Presentation

Qt5WebEngineCore and calloc

  • A portion of my application allows users to import an image and vectorize it. During this process, different scaling options are given based on whether there is enough available memory for all the internal copies of the image to be created. To do this, I would simply use calloc to actually allocate temporary buffers for what would be needed. Below I have a small snippet of the allocation code:

    for (i = 0; i < totalImages; i++)
    		void *pAllocation = calloc(totalImageSize, 1);
    		if (pAllocation)

    This worked fine on Qt5.2.1 (maybe not the best way to do this but it did work).

    But I needed to add web content to my welcome screen so I decided to move to Qt5.4.1 and use the QtWebEngine which appears to be working fine. After this addition, my vectorization code appears to be crashing when trying to run calloc and allocate more memory then what is available. Throwing this into debug and looking at the stack I find the following:

    0 IsSandboxedProcess Qt5WebEngineCored 0x11f75034
    1 std::_New_handler_interface stdhndlr.cpp 13 0x573cce09
    2 _callnewh handler.cpp 135 0x54e6bfc0
    3 _nh_malloc_dbg_impl dbgheap.c 255 0x54f4dc01
    4 _calloc_dbg_impl dbgheap.c 601 0x54f4ce22
    5 _calloc_dbg dbgheap.c 652 0x54f4cd9a
    6 calloc dbgcalloc.c 56 0x54f5e957
    ... <More>

    I simply wanted the QtWebEngine to show some web content but it seems to have hooked itself into locations that I would not have even expected it to be.

    Am I going to need to wrap my calloc calls in a try/catch or is there something else I can do without having to completely rewrite this piece of code due to web engine hooking into a basic call like calloc?

    Thank you for your time.

  • I have created a bug for this and will see where it goes from there.


Log in to reply