[SOLVED]QFile triggers an exception



  • Hi,
    something really weird is happening with my code .
    this line triggers this error :
    error:
    [quote]
    Exception at 0x7601b727, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at f:\dd\vctools\crt\crtw32\heap\new.cpp:63
    [/quote]

    code :
    [code]
    QFile* newClear= new QFile("cmd.scr");
    [/code]
    i don't understand since in other source file i use the same line code but with different file name .



  • Files with an SCR extension might be treated differently than other files. I guess it depends where you are trying to put it and possibly how picky your virus scanner is.

    Operator new can throw an exception for various reasons. Maybe you ran out of memory and was not able to allocate any more for example. If you don't catch the exception your program will shut down.

    Maybe adding the try/catch block with the proper exception handler class for 'new' and see if there is anything useful reported back (such an error code or error text).



  • Hi , sorry for late reply .
    I tried changing the file name it didn't work .
    more precisely it works kindda weird sometimes the allocation is successful and sometimes not .
    i wrote the try, catch as follows but it still crashed :
    @
    try{
    QString t = QDir::currentPath();
    Dir = QDir::cleanPath(t);
    newClear= new QFile("cmd.in");
    if (!newClear->open(QIODevice::WriteOnly | QIODevice::Text)) {
    return -1;
    }
    }catch(std::exception& e){
    std::cout << e.what() << std::endl;
    }catch(...){
    std::cout << "damn" << std::endl;
    }
    @

    also i don't think its a memory problem because according to the task manager i have like 3 g free .
    also you might notice the :

    @QString t = QDir::currentPath();
    Dir = QDir::cleanPath(t);
    @
    instead of :
    @
    Dir = QDir::cleanPath(QDir::currentPath());
    @
    it is because sometimes it crashed at those lines .

    if this helps , the exception opens the assembly file containing,starting with the function ntdll!RtlReportCriticalFailure:
    also this is the trace output of the debugger :
    [quote]
    0 RtlReportCriticalFailure ntdll 0x777be625
    1 RtlpReportHeapFailure ntdll 0x777bf559
    2 RtlpLogHeapFailure ntdll 0x777bf639
    3 RtlpAllocateHeap ntdll 0x7777aede
    4 RtlAllocateHeap ntdll 0x77723cce
    5 RtlDebugAllocateHeap ntdll 0x777c0d1b
    6 RtlpAllocateHeap ntdll 0x7777ae1e
    7 RtlAllocateHeap ntdll 0x77723cce
    8 _heap_alloc_base malloc.c 58 0x6434c6e1
    9 _heap_alloc_dbg_impl dbgheap.c 431 0x6435d72f
    10 _nh_malloc_dbg_impl dbgheap.c 239 0x6435dbcd
    11 _nh_malloc_dbg dbgheap.c 302 0x6435db7a
    12 malloc dbgmalloc.c 56 0x6435e5a9
    13 QArrayData::allocate qarraydata.cpp 101 0x4b746a
    14 QTypedArrayData<unsigned short>::allocate qarraydata.h 228 0x56e724
    15 QString::QString qstring.cpp 1460 0x55f6ad
    16 QUtf16::convertToUnicode qutfcodec.cpp 462 0x814378
    17 QString::fromUtf16 qstring.cpp 4538 0x55e7e4
    18 QString::fromWCharArray qstring.h 895 0x452f26
    19 QFileSystemEngine::currentPath qfilesystemengine_win.cpp 1369 0x6e2438
    20 QDir::currentPath qdir.cpp 1876 0x64bcb9 <==============================================
    21 sendToFTPServer utils.cpp 150 0xe3f55d
    22 Signatures::read_pcaps_path signatures.cpp 947 0xdcb3e1
    23 Signatures::qt_static_metacall moc_signatures.cpp 203 0xe54be1
    24 QMetaObject::activate qobject.cpp 3680 0x7ba429
    25 QMetaObject::activate qobject.cpp 3546 0x7b9e81
    26 File_browser::open_clicked moc_file_browser.cpp 154 0xe54fba
    27 File_browser::on_open_clicked file_browser.cpp 127 0xdeb330
    28 File_browser::qt_static_metacall moc_file_browser.cpp 96 0xe54eab
    29 File_browser::qt_metacall moc_file_browser.cpp 141 0xe54e0b
    30 QMetaObject::metacall qmetaobject.cpp 309 0x77b7a0
    31 QMetaObject::activate qobject.cpp 3695 0x7ba4c6
    32 QMetaObject::activate qobject.cpp 3546 0x7b9e81
    33 QAbstractButton::clicked moc_qabstractbutton.cpp 297 0x63f51a8b
    34 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 544 0x63bfb407
    35 QAbstractButtonPrivate::click qabstractbutton.cpp 536 0x63bfa98b
    36 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1141 0x63bf9df2
    37 QWidget::event qwidget.cpp 7966 0x63aebb2c
    38 QAbstractButton::event qabstractbutton.cpp 1098 0x63bf9951
    39 QPushButton::event qpushbutton.cpp 682 0x63cbc80b
    40 QApplicationPrivate::notify_helper qapplication.cpp 3522 0x63aa3a6e
    41 QApplication::notify qapplication.cpp 3089 0x63aa026e
    42 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x76f607
    43 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 240 0x886188
    44 QApplicationPrivate::sendMouseEvent qapplication.cpp 2562 0x63aa4dc3
    45 QWidgetWindow::handleMouseEvent qwidgetwindow.cpp 507 0x63b287cb
    46 QWidgetWindow::event qwidgetwindow.cpp 180 0x63b279ae
    47 QApplicationPrivate::notify_helper qapplication.cpp 3522 0x63aa3a6e
    48 QApplication::notify qapplication.cpp 2975 0x63a9fc37
    49 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x76f607
    50 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 240 0x886188
    51 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 1715 0x6345ba4f
    52 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 1516 0x6345d979
    53 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 579 0x6343ffd1
    54 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 89 0x60e4a8b1
    55 qt_internal_proc qeventdispatcher_win.cpp 423 0x806ff0
    56 InternalCallWinProc USER32 0x752c62fa
    57 UserCallWinProcCheckWow USER32 0x752c6d3a
    58 DispatchMessageWorker USER32 0x752c77c4
    59 DispatchMessageW USER32 0x752c788a
    60 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 757 0x807a4f
    61 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 80 0x60e4a7cc
    62 QEventLoop::processEvents qeventloop.cpp 137 0x76b48c
    63 QEventLoop::exec qeventloop.cpp 212 0x76b682
    64 QCoreApplication::exec qcoreapplication.cpp 1188 0x76dc12
    65 QGuiApplication::exec qguiapplication.cpp 1451 0x6345a618
    66 QApplication::exec qapplication.cpp 2768 0x63a9f739
    67 main main.cpp 10 0xdb7f0e
    68 WinMain qtmain_win.cpp 131 0xe5a85a
    69 __tmainCRTStartup crtexe.c 618 0xe59fdf
    70 WinMainCRTStartup crtexe.c 466 0xe59d9d
    71 BaseThreadInitThunk kernel32 0x757633ca
    72 __RtlUserThreadStart ntdll 0x77729ed2
    73 _RtlUserThreadStart ntdll 0x77729ea5
    [/quote]


  • Lifetime Qt Champion

    Hi,

    3GB of free RAM doesn't mean that it's accessible to your application. If you are running a 32bit application it can't use more than 2GB. Is your application using that much ?



  • Hi ,
    thanks for the reply but in the end , i just dumped the library that im using which is libssh (c implementation) and all its malloc/free things ,
    is there a way to delete this thread , because its not relevant anymore .

    again thanks , and sorry for the bother .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.