Click here to Skip to main content
15,936,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: More about "system" call - sort of repost Pin
k505422-Jan-22 5:19
mvek505422-Jan-22 5:19 
GeneralRe: More about "system" call - sort of repost Pin
Richard MacCutchan22-Jan-22 6:28
mveRichard MacCutchan22-Jan-22 6:28 
QuestionMessage Closed Pin
21-Jan-22 6:37
Member 1496877121-Jan-22 6:37 
AnswerRe: How to read "compiier output " Pin
k505421-Jan-22 7:15
mvek505421-Jan-22 7:15 
GeneralMessage Closed Pin
21-Jan-22 8:25
Member 1496877121-Jan-22 8:25 
GeneralRe: How to read "compiier output " Pin
k505421-Jan-22 11:36
mvek505421-Jan-22 11:36 
QuestionMessage Closed Pin
20-Jan-22 14:58
Member 1496877120-Jan-22 14:58 
AnswerRe: Another long shot... Pin
k505420-Jan-22 16:40
mvek505420-Jan-22 16:40 
First, make sure you're creating a debug build. Whatever IDE you're using should have a Build or Compile config section, so take a look and make sure that's set. Your IDE should have a built in link to the debugger, so just run the program in the debugger. When the error is thrown, the debugger should stop the program and allow you to examine the state of the program. If you need to use the command line, here's an example to help you get started:
Shell
$ cat bad_alloc.cpp
 #include <iostream>

int main()
{
    size_t lim = 2;
    while(true)
    {
        int *arr = new int[lim];
        delete[] arr;
        lim *= 2;
    }
    return 0;
}
$ # That will eventually try to allocate too much memory
$ # compile with gdb, in 32 bit mode to get a quick crash
$ g++ -m32 -ggdb  bad_alloc.cpp -o bad_alloc
$ # debug the program
$ gdb bad_alloc
 #
 # GDB startup messages snipped out
 #
Reading symbols from bad_alloc...
(gdb) run
Starting program: /home/ebacon/tmp/c++/bad_alloc 
terminate called after throwing an instance of 'std::bad_array_new_length'
  what():  std::bad_array_new_length

Program received signal SIGABRT, Aborted.
0xf7fce559 in __kernel_vsyscall ()
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.32-10.fc33.i686 libgcc-10.3.1-1.fc33.i686
(gdb) # take a look at the backtrace
(gdb) bt
 #0  0xf7fce559 in __kernel_vsyscall ()
 #1  0xf7d2759a in raise () from /lib/libc.so.6
 #2  0xf7d0f3d0 in abort () from /lib/libc.so.6
 #3  0x0804c829 in __gnu_cxx::__verbose_terminate_handler() [clone .cold] ()
 #4  0x080dee78 in __cxxabiv1::__terminate(void (*)()) ()
 #5  0x080def01 in std::terminate() ()
 #6  0x0804dbb0 in __cxa_throw ()
 #7  0x0804a7ee in __cxa_throw_bad_array_new_length ()
 #8  0x0804d9f7 in main () at bad_alloc.cpp:8
(gdb) # all the frames except the last are part of the STL, 
(gdb) # so we're probably only interested in frame 8 
(gdb) frame 8
 #8  0x0804d9f7 in main () at bad_alloc.cpp:8
8               int *arr = new int[lim];
(gdb) # The 8 in the line above refers to line 8 of the source 
(gdb) # print the value of lim 
(gdb) p lim
$1 = 536870912
(gdb) quit
A debugging session is active.
        Inferior 1 [process 3076940] will be killed.
Quit anyway? (y or n) y
$
Hopefully, that's enough to get you started. If you need more, then Google is your friend.
Keep Calm and Carry On

QuestionMessage Closed Pin
18-Jan-22 11:04
Member 1496877118-Jan-22 11:04 
AnswerRe: Passing system function to QProcess - need syntax help Pin
k505418-Jan-22 11:37
mvek505418-Jan-22 11:37 
Questionwindow.chrome.webview.postmessage from child html to main c++ app (webView2) Pin
Member 1543991717-Jan-22 16:20
Member 1543991717-Jan-22 16:20 
QuestionDDX_Text embedding nulls on UpdateData(TRUE) Pin
ForNow13-Jan-22 16:50
ForNow13-Jan-22 16:50 
AnswerRe: DDX_Text embedding nulls on UpdateData(TRUE) Pin
Peter_in_278013-Jan-22 19:00
professionalPeter_in_278013-Jan-22 19:00 
GeneralRe: DDX_Text embedding nulls on UpdateData(TRUE) Pin
ForNow13-Jan-22 20:10
ForNow13-Jan-22 20:10 
GeneralRe: DDX_Text embedding nulls on UpdateData(TRUE) Pin
Richard MacCutchan13-Jan-22 20:54
mveRichard MacCutchan13-Jan-22 20:54 
GeneralRe: DDX_Text embedding nulls on UpdateData(TRUE) Pin
ForNow14-Jan-22 2:11
ForNow14-Jan-22 2:11 
GeneralRe: DDX_Text embedding nulls on UpdateData(TRUE) Pin
Richard MacCutchan14-Jan-22 3:19
mveRichard MacCutchan14-Jan-22 3:19 
GeneralRe: DDX_Text embedding nulls on UpdateData(TRUE) Pin
ForNow14-Jan-22 3:29
ForNow14-Jan-22 3:29 
GeneralRe: DDX_Text embedding nulls on UpdateData(TRUE) Pin
Richard MacCutchan14-Jan-22 4:07
mveRichard MacCutchan14-Jan-22 4:07 
QuestionNow none of my .h header file changes seem to take Pin
ForNow11-Jan-22 17:30
ForNow11-Jan-22 17:30 
AnswerRe: Now none of my .h header file changes seem to take Pin
Richard MacCutchan11-Jan-22 23:18
mveRichard MacCutchan11-Jan-22 23:18 
GeneralRe: Now none of my .h header file changes seem to take Pin
ForNow12-Jan-22 1:28
ForNow12-Jan-22 1:28 
GeneralRe: Now none of my .h header file changes seem to take Pin
Victor Nijegorodov12-Jan-22 2:14
Victor Nijegorodov12-Jan-22 2:14 
GeneralRe: Now none of my .h header file changes seem to take Pin
ForNow12-Jan-22 2:17
ForNow12-Jan-22 2:17 
GeneralRe: Now none of my .h header file changes seem to take Pin
Richard MacCutchan12-Jan-22 2:46
mveRichard MacCutchan12-Jan-22 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.