Меню

Debug error c abort has been called ошибка

  • Forum
  • Beginners
  • Debug Error abort() has been called

Debug Error abort() has been called

I tried debugging it when the error window came up by clicking continue and a breakpoint poped up at min = stoi(temp); which is in the Read Method. idk why though. Idk if this helps but i’m using a static library containing all the classes then linking it to main. but i see no errors

main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include "Album.h"

using namespace std;

int main() 
{
	Song total;
	int choice;
	string m_filename;
	Album x;
	cout << "Album Program" << endl;
	cout << "----------" << endl;
	cout << "1 - Read ablbum info from a file" << endl;
	cout << "2 - Write album info to a file" << endl;
	cout << "3 - Show all album info on screen" << endl;
	cout << "4 - Show ablum time on screen" << endl;
	cout << "5 - Exit" << endl;
	cout << "Enter Choice: ";
	cin >> choice;
	cout << endl;
	cout << "Enter File Name: ";
	cin >> m_filename;

	for (int i = 0; i < 6; i++)
	{
		switch (choice)
		{
		case 1:
			x.Read(m_filename);
			cout << "Enter Choice: ";
			cin >> choice;

			break;
		case 2:
			x.Write(m_filename);
			cout << "Enter Choice: ";
			cin >> choice;

			break;
		case 3:
			x.Display();
			cout << "Enter Choice: ";
			cin >> choice;


			break;
		case 4:
			x.CalcTotalTime();
			cout << "Enter Choice: ";
			cin >> choice;


		case 5:
			return 0;
		}

	}


	return 0;
}

Album.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "Album.h"
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
Album::Album()
{
	Title = "no name";
}

string Album::GetTitle()
{
	return Title;
}


void Album::SetTitle(string NewTitle)
{
	Title = NewTitle;
}

Time Album::CalcTotalTime()
{
	int TotalMin = 0;
	int TotalSec = 0;
	Time A;
	for (int i = 0; i < 5; i++)
	{
		TotalMin = TotalMin + S[i].GetTime().GetMinutes();
	}

	for (int i = 0; i <= 5; i++)
	{
		TotalSec = TotalSec + S[i].GetTime().GetSeconds();

		if (TotalSec > 59)
		{

			TotalMin++;
			TotalSec = TotalSec - 60;
		}
	}
	A.SetMinutes(TotalMin);
	A.SetSeconds(TotalSec);
	return A;
}

void Album::Read(string filename)
{
	string Country;
	string AlbumName;
	string SongTitle;
	string temp;
	ifstream Read;
//	Time m_Time;
//	int sec;
//	int min;
	Read.open(filename);
	m_Artist.SetName(AlbumName);
	m_Artist.SetCountryofOrigin(Country);
	getline(Read, Title);
	getline(Read, AlbumName);
	getline(Read, Country);
	for (int i = 0; i < 6; i++)
	{
		Time m_Time;
		int sec;
		int min;
		getline(Read, SongTitle);
		S[i].SetTitle(SongTitle);
		
		getline(Read, temp);

		min = stoi(temp);
		m_Time.SetMinutes(min);
		
		getline(Read, temp);

		sec = stoi(temp);
		m_Time.SetSeconds(sec);

		S[i].SetTime(m_Time);

	}
}

void Album::Write(string filename)
{
	cout << "Enter File Name" << endl;
	cin >> filename;
	ofstream Write;
	Write.open(filename);
	Write << GetTitle() << endl;
	Write << m_Artist.GetName() << endl;
	Write << m_Artist.GetCountryofOrigin();
	


	for (int i = 0; i < 6; i++)
	{
		Write << S[i].GetTitle() << endl;
		Write << S[i].GetTime().GetMinutes() << endl;
		Write << S[i].GetTime().GetSeconds() << endl;

	}
}

void Album::Display()
{
	cout << setw(12) << "Title:" << GetTitle() << endl;
	cout << setw(12) << "Artist:" << m_Artist.GetName() << endl;
	cout << setw(12) << "Title:" << m_Artist.GetCountryofOrigin() << endl;

}

Last edited on

a breakpoint poped up at min = stoi(temp); which is in the Read Method

Very good, so you know where the problem is.

You need to inspect with the debugger what value temp has.
If temp is not a valid int you need to find out how it got there.

So I didnt see anything that raised my suspicion but i saw that the int min wasnt never given a value. I’m still not sure if thats the problem but i set min and sec to 0 reran it and again it picked up a breaker but in a different location, now in the main.cpp cout << "Enter Choice: "; and I just dont see whats wrong with that code.

Edit: nevermind its still at the min = stoi(temp);

Last edited on

So in the debugger i noticed my temp has No value at all. So i made temp equal 0 temp = '0'; right before the loop and it seems to got rid of the error but still the program isnt working properly

Ok, the next step is to find out why it didn’t have a value.
Probably sth. wrong with your read function.
Without knowing the file format it’s impossible to tell.

Topic archived. No new replies allowed.

  • Remove From My Forums
  • Question

  • Hello im trying to use threads, but i cant stop the threads without getting the error: Abort() has been called.

    using namespace std;
    
    void print1()
    {
    	//while(true)
    	cout << "Function 1" << endl;
    }
    
    void print2()
    {
    	//while(true)
    	cout << "Function 2" << endl;
    }
    
    int main(int argc, char argv[])
    {
    	//Creates Threads
    	thread PrimaryThread(print1);
    	thread SecondaryThread(print2);
    
    	//Assigns the threas to pointers
    	thread* pPrimeThread = &PrimaryThread;
    	thread* pSecondaryThread = &PrimaryThread;
    
    	LPDWORD pExitCode = 0;
    	if(GetExitCodeThread(pPrimeThread,pExitCode) != 0)
    	{
    		ExitThread((DWORD)pExitCode);
    		cout << "Thread Closed" << endl;
    
    		if(CloseHandle(pPrimeThread))
            {
                cout << "Handle closed" << endl;
            }
    
    	}
    
    	system("pause");
        return 0;
    
    }

Answers

  • On 2/12/2013 3:36 AM, Farmek wrote:

    But it still gives me a «Abort() has been called» when i try to exit the application.

    You must call join() or detach() methods on thread object before that object is destroyed. If ~thread destructor is reached while the object is still attached to a thread of execution (in other words, while joinable() returns true), the destructor calls
    terminate().


    Igor Tandetnik

    • Marked as answer by

      Tuesday, February 12, 2013 3:12 PM

description title ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords

Learn more about: abort

abort

07/07/2022

abort

_o_abort

msvcrt.dll

msvcr80.dll

msvcr90.dll

msvcr100.dll

msvcr100_clr0400.dll

msvcr110.dll

msvcr110_clr0400.dll

msvcr120.dll

msvcr120_clr0400.dll

ucrtbase.dll

api-ms-win-crt-runtime-l1-1-0.dll

DLLExport

apiref

STDLIB/abort

abort

aborting current process

abort function

processes, aborting

Aborts the current process and returns an error code.

[!NOTE]
Do not use this method to shut down a Microsoft Store app or Universal Windows Platform (UWP) app, except in testing or debugging scenarios. Programmatic or UI ways to close a Store app are not permitted according to the Microsoft Store policies. For more information, see UWP app lifecycle.

Syntax

Return value

abort doesn’t return control to the calling process. By default, it checks for an abort signal handler and raises SIGABRT if one is set. Then abort terminates the current process and returns an exit code to the parent process.

Remarks

Microsoft Specific

By default, when an app is built with the debug runtime library, the abort routine displays an error message before SIGABRT is raised. For console apps running in console mode, the message is sent to STDERR. Windows desktop apps and console apps running in windowed mode display the message in a message box. To suppress the message, use _set_abort_behavior to clear the _WRITE_ABORT_MSG flag. The message displayed depends on the version of the runtime environment used. For applications built by using the most recent versions of Visual C++, the message resembles this one:

R6010 — abort() has been called

In previous versions of the C runtime library, this message was displayed:

This application has requested the Runtime to terminate it in an unusual way. Please contact the application’s support team for more information.

When the program is compiled in debug mode, the message box displays options to Abort, Retry, or Ignore. If the user chooses Abort, the program terminates immediately and returns an exit code of 3. If the user chooses Retry, a debugger is invoked for just-in-time debugging, if available. If the user chooses Ignore, abort continues normal processing.

In both retail and debug builds, abort then checks whether an abort signal handler is set. If a non-default signal handler is set, abort calls raise(SIGABRT). Use the signal function to associate an abort signal handler function with the SIGABRT signal. You can perform custom actions—for example, clean up resources or log information—and terminate the app with your own error code in the handler function. If no custom signal handler is defined, abort doesn’t raise the SIGABRT signal.

By default, in non-debug builds of desktop or console apps, abort then invokes the Windows Error Reporting Service mechanism (formerly known as Dr. Watson) to report failures to Microsoft. This behavior can be enabled or disabled by calling _set_abort_behavior and setting or masking the _CALL_REPORTFAULT flag. When the flag is set, Windows displays a message box that has text something like «A problem caused the program to stop working correctly.» The user can choose to invoke a debugger with a Debug button, or choose the Close program button to terminate the app with an error code that’s defined by the operating system.

If the Windows error reporting handler isn’t invoked, then abort calls _exit to terminate the process with exit code 3 and returns control to the parent process or the operating system. _exit doesn’t flush stream buffers or do atexit/_onexit processing.

For Windows compatibility reasons, when abort calls _exit, it may invoke the Windows ExitProcess API, which in turn allows DLL termination routines to run. Destructors aren’t run in the executable, but the same may not be true of DLLs loaded in the executable’s process space. This behavior doesn’t strictly conform to the C++ standard. To immediately terminate a process including any DLLs, use the Windows TerminateProcess API. You can also register an abort signal handler that invokes TerminateProcess for standard-compliant behavior. Compliant behavior may come at some cost in Windows compatibility.

For more information about CRT debugging, see CRT debugging techniques.

End Microsoft Specific

By default, this function’s global state is scoped to the application. To change it, see Global state in the CRT.

Requirements

Routine Required header
abort <process.h> or <stdlib.h>

Example

The following program tries to open a file and aborts if the attempt fails.

// crt_abort.c
// compile with: /TC
// This program demonstrates the use of
// the abort function by attempting to open a file
// and aborts if the attempt fails.

#include  <stdio.h>
#include  <stdlib.h>

int main( void )
{
    FILE    *stream = NULL;
    errno_t err = 0;

    err = fopen_s(&stream, "NOSUCHF.ILE", "r" );
    if ((err != 0) || (stream == NULL))
    {
        perror( "File could not be opened" );
        abort();
    }
    else
    {
        fclose( stream );
    }
}
File could not be opened: No such file or directory

See also

Using abort
abort function
Process and environment control
_exec, _wexec functions
exit, _Exit, _exit
raise
signal
_spawn, _wspawn functions
_DEBUG
_set_abort_behavior

Question How to communicate with server in vc++? Pin

Le@rner4-Jul-11 21:35

Le@rner 4-Jul-11 21:35 
Answer Re: How to communicate with server in vc++? Pin

Rajesh R Subramanian4-Jul-11 22:00

professional Rajesh R Subramanian 4-Jul-11 22:00 
Answer Re: How to communicate with server in vc++? Pin

T.RATHA KRISHNAN4-Jul-11 22:34

T.RATHA KRISHNAN 4-Jul-11 22:34 
General Re: How to communicate with server in vc++? Pin

Le@rner4-Jul-11 22:53

Le@rner 4-Jul-11 22:53 
Answer Re: How to communicate with server in vc++? Pin

T.RATHA KRISHNAN5-Jul-11 1:11

T.RATHA KRISHNAN 5-Jul-11 1:11 
Answer Re: How to communicate with server in vc++? Pin

Albert Holguin5-Jul-11 6:07

professional Albert Holguin 5-Jul-11 6:07 
Answer Re: How to communicate with server in vc++? Pin

David W. Young5-Jul-11 7:01

David W. Young 5-Jul-11 7:01 
Question “Debug Error! R6010 -abort() has been called”- how to find the error? Pin

huangzhtao4-Jul-11 18:04

huangzhtao 4-Jul-11 18:04 
I compiled a MFC application in debug mode.
When I run the program, most time, it was OK, but in a few times, it occurred following error:

Debug Error!

Program:
......XXX.exe

R6010
-abort() has been called

(Press Retry to debug the application)

Last night, I left the program running, it also occurred such error.
Now I let the program run for two hours,but the error has not occurred yet.
It seems the error occurred randomly, how can I get rid of the annoying problem Dead | X| .

Sign In·View Thread  
Answer Re: “Debug Error! R6010 -abort() has been called”- how to find the error? Pin

Richard MacCutchan5-Jul-11 1:12

mve Richard MacCutchan 5-Jul-11 1:12 
Answer Re: “Debug Error! R6010 -abort() has been called”- how to find the error? Pin

Albert Holguin5-Jul-11 6:00

professional Albert Holguin 5-Jul-11 6:00 
Question Re: “Debug Error! R6010 -abort() has been called”- how to find the error? Pin

David Crow5-Jul-11 6:46

David Crow 5-Jul-11 6:46 
Question How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Odysseas Z4-Jul-11 9:54

Odysseas Z 4-Jul-11 9:54 
Question Re: How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Mark Salsbery4-Jul-11 10:01

Mark Salsbery 4-Jul-11 10:01 
Answer Re: How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Odysseas Z4-Jul-11 10:05

Odysseas Z 4-Jul-11 10:05 
General Re: How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Mark Salsbery4-Jul-11 10:12

Mark Salsbery 4-Jul-11 10:12 
General Re: How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Odysseas Z4-Jul-11 10:20

Odysseas Z 4-Jul-11 10:20 
General Re: How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Mark Salsbery4-Jul-11 10:30

Mark Salsbery 4-Jul-11 10:30 
General Re: How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Odysseas Z4-Jul-11 10:33

Odysseas Z 4-Jul-11 10:33 
General Re: How to initialize a CProgressCtrl object in a CDialog derived object. Pin

Mark Salsbery4-Jul-11 10:35

Mark Salsbery 4-Jul-11 10:35 
Question How to implement CALLBACK_THREAD ( MFC worker thread) in waveInOpen API ? Pin

Vaclav_4-Jul-11 5:25

Vaclav_ 4-Jul-11 5:25 
Answer Re: How to implement CALLBACK_THREAD ( MFC worker thread) in waveInOpen API ? Pin

«_Superman_»4-Jul-11 8:33

professional «_Superman_» 4-Jul-11 8:33 
General Re: How to implement CALLBACK_THREAD ( MFC worker thread) in waveInOpen API ? Pin

Vaclav_4-Jul-11 8:48

Vaclav_ 4-Jul-11 8:48 
Question How to store Hexa value in a Text field of a table Pin

Amrit Agr3-Jul-11 22:25

Amrit Agr 3-Jul-11 22:25 
Answer Re: How to store Hexa value in a Text field of a table Pin

Randor 4-Jul-11 0:53

professional Randor 4-Jul-11 0:53 
General Re: How to store Hexa value in a Text field of a table Pin

LiangGuangLin4-Jul-11 3:58

LiangGuangLin 4-Jul-11 3:58 

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Debian ошибка установки пакета
  • Debian ошибка при установке