1073741510 код ошибки

I was running a c++ program in Code Blocks, but I got the error:
«Process terminated with status -1073741510».
By now I figured out that the error occurs at:

new_list = new char[number_of_symbols + 1];

The problem is that I can’t figure out for the life of me what I’m doing wrong here. To give more context I’ve put the complete code below.

#include <iostream>
#include <math.h>
#include <time.h>

using namespace std;

struct transition{
  int write_symbol;
  int move_head;
  int next_state;
};

class TM{
public:
  TM();
  ~TM();
  void add_transition(int, char, int, char, int);
  void remove_transition(int, char);
  void run();
  void run(char*, int);
private:
  int current_state;
  int head_position;
  int number_of_states;
  int number_of_symbols;
  char* symbol_list;
  transition** action_table;
  void add_state(int);
  int add_symbol(char);
  void print(char*);
  void free_action_table();
};

TM::TM(){
  number_of_states = 0;
  number_of_symbols = 0;
}

TM::~TM(){
  free_action_table();
}

void TM::add_transition(int p, char sigma, int q, char tau, int D){
  int symbol_id1, symbol_id2;
  cout << "Gaat dit goed?" << endl;
  add_state(p);
  cout << "Gaat dat goed?" << endl;
  add_state(q);
  cout << "En gaat deze goed?" << endl;
  symbol_id1 = add_symbol(sigma);
  cout << "Gaat die ook goed?" << endl;
  symbol_id2 = add_symbol(tau);
  cout << "Gaat misschien alles goed?" << endl;
  action_table[symbol_id1][p].write_symbol = symbol_id2;
  action_table[symbol_id1][p].next_state = q;
  action_table[symbol_id1][p].move_head = D;
  cout << "Alles gaat goed!" << endl;
}

void TM::add_state(int state){
  transition** new_table;
  if(state >= number_of_states){
    new_table = new transition*[number_of_symbols];
    for(int i = 0; i < number_of_symbols; i++){
      new_table[i] = new transition[state + 1];
      for(int j = 0; j < number_of_states; j++){
        new_table[i][j] = action_table[i][j];
      }
      for(int j = number_of_states; j <= state; j++){
        new_table[i][number_of_states - 1].write_symbol = -1;
        new_table[i][number_of_states - 1].next_state = -2;
        new_table[i][number_of_states - 1].move_head = 0;
      }
    }
    free_action_table();
    number_of_states = state + 1;
    action_table = new_table;
  }
}

int TM::add_symbol(char symbol){
  transition** new_table;
  char* new_list;
  cout << "Gaat hier iets fout?" << endl;
  for(int i = 0; i < number_of_symbols; i++){
    if(symbol_list[number_of_symbols] == symbol){
      return i;
    }
  }
  new_table = new transition*[number_of_symbols + 1];
  cout << "Gaat daar iets fout?" << endl;
  new_list = new char[number_of_symbols + 1];
  cout << "Of misschien hier?" << endl;
  for(int i = 0; i < number_of_symbols; i++){
    new_table[i] = new transition[number_of_states];
    new_list[i] = symbol_list[i];
    for(int j = 0; j < number_of_states; j++){
      new_table[i][j] = action_table[i][j];
    }
  }
  for(int j = 0; j < number_of_states; j++){
    new_table[number_of_symbols][j].write_symbol = 0;
    new_table[number_of_symbols][j].next_state = -2;
    new_table[number_of_symbols][j].move_head = 0;
  }
  cout << "Zou het kunnen?" << endl;
  new_list[number_of_symbols] = symbol;
  free_action_table();
  if(number_of_symbols > 0){
    delete[] symbol_list;
  }
  symbol_list = new_list;
  number_of_symbols++;
  action_table = new_table;
  cout << "Alles gaat goed!" << endl;
  return number_of_symbols - 1;
}

void TM::free_action_table(){
  for(int i = 0; i < number_of_symbols; i++){
    delete[] action_table[i];
  }
  delete[] action_table;
}

int main(){

  TM one = TM();
  one.add_transition(0,'0',0,'1',0);
  one.add_transition(0,'1',-1,'1',0);

  return 0;
}

After running I got the following output:

Gaat dit goed?
Gaat dat goed?
En gaat deze goed?
Gaat hier iets fout?
Gaat daar iets fout?
Of misschien hier?
Zou het kunnen?
Alles gaat goed!
Gaat die ook goed?
Gaat hier iets fout?
Gaat daar iets fout?

Process returned -1073741819 (0xC0000005)   execution time : 2.028 s
Press any key to continue.

This would imply that something is wrong with the line I mentioned before, but I can’t figure out why. Can someone tell me what I’m doing wrong here?

Koptina, если приложение прям консольное, то по кресту вы получаете системный вызов, эквивалентный Ctrl+C.
У QCoreApplication внутри крутится своя очередь сообщений, к которой вы имеете доступ из любого объекта. Нужно покапать, какие из наследников QEvent относятся к консольным функциям, и в какой из методов QObject он прилетает (там есть разбиение по смыслу, читайте документацию).

Правильная реализация в вашем случае будет такая:
В объекте перегружаете event() и timerEvent(), в конструкторе создаёте повторяющийся таймер startTimer(), в timerEvent делаете ваши периодические дела, в деструкторе освобождаете ресурсы. Если нужно, перехватываете сообщение о Ctrl+C в event() и изменяете код возврата приложения (тупо вызываете QCoreApplication::exit(0)).

Главное, что нужно запомнить в работе приложения: spice must flow. Очередь сообщений должна крутиться. Это значит, что все тяжелые алгоритмы должны быть разбиты на итерации, и уже отдельные итерации (или итерации итераций) должны обрабатываться из очереди сообщений по таймеру. Есть аварийный метод QCoreApplication::processEvents(), но это именно что аварийный метод, и его использование, в общем-то, может помножить систему на ноль или поделить ресурсы пеки на бесконечность.

Например

для подсчётов алгоритма вы можете создавать разделяемые ресурсы (общие между приложениями), которые будут освобождены в самом конце алгоритма. Тогда, если вставить processEvent, то, если алгоритм не доработал до конца, ресурс освобождён не будет. Решение — все ресурсы вынести вне алгоритма, а его самого разбить на несколько кусков, каждый из которых будет вызываться из очереди сообщений.

C++ (Qt)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
QObject::timerEvent(){
  foo();
}
 
void foo() {
  for (int i = 0; i < 1000; ++i) qDebug("ping");
  QCoreApplication::processEvents();
  for (int i = 0; i < 1000; ++i) qDebug("pong");
}
 
// VVV
 
QObject::timerEvent(){
  m_foo_stage = foo(m_foo_stage );
}
int foo(int stage) {
  if (stage == 0) for (int i = 0; i < INT_MAX; ++i) qDebug("ping");
  if (stage == 1) for (int i = 0; i < INT_MAX; ++i) qDebug("pong");
  return !stage;
}

According to:

Jobs failing on Windows with Exit Code 0xC000013A

Globally speaking, Exit Code 0xC000013A means that the application terminated as a result of a CTRL+C or  closing command prompt window

I copied, compiled and ran your code. With x=9, the code is stuck in the while loop forever, so I had to close the program using the close button ([x] button in the upper right corner). That generated the 0xc000013a error code. (With x=7 the program is not stuck in the while loop so it is able to exit normally.)

More specifically, for x=9 the program is stuck in the while loop because when i=3 then (x % i) == 0 (9 mod 3 = 0) and the statement i = i + 1 never executes. So i never increments beyond 3 and i < x (3 < 9) is always true.

So the immediate problem is that your code never exits (for x=9) and you have to stop it, presumably by clicking the close button. But the larger issue is that your logic is bad and your program isn’t working the way you think it is.

For example, when x=9 and i=2, then (x % i) != 0 and that leads to b = b + 1. That means b > 0 and your program should return 1, which you indicated meant prime in the case of x=7. But 9 is not prime.

Also, isPrime has a return type of bool but you are returning int.

  • Remove From My Forums
  • Question

  • I repeatedly get this failure on a particular package.  It doesn’t happen with every machine/collection the software is advertised to.  And if I manually run the installation the software installs fine.  I re-run the advertisement often the
    installation will also succeed. The issue is just so intermittent and I can’t figure out exactly what the problem is.

    A failure exit code of -1073741510 was returned. User context: NT AUTHORITYSYSTEM Possible cause: Systems Management Server (SMS) determines status for each program it executes. If SMS cannot find or correlate any installation status Management Information
    Format (MIF) files for the program, it uses the program’s exit code to determine status. An exit code of -1073741510 is considered a failure. Solution: For more information on the exit code, refer to the documentation for the program you are distributing.

    Has anyone else had any experiences like this?

Answers

  • I’d have to say the groupchat client seems to be under-documented, especially the setup aspects (I haven’t discovered anything about the /unattend argument so far, so am wondering how you came across that? or found it via the trusty old «/?» method..)

    maybe ask about this in
    http://social.technet.microsoft.com/Forums/en-US/ocsclients/threads

    or get onto CSS


    Don

    • Marked as answer by

      Saturday, October 8, 2011 4:01 AM

Hi,

I am getting the error exited with code -1073741510 with all console applications even the one with just QCoreApplication and the event loop, i.e.:

@
#include <QCoreApplication>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

return a.exec();

}
@

The error occurs after closing the window or using CTRL+C. Outputting to Qt Creator «hangs» the application with no other way than killing the process to end it. Running Qt Creator as administrator also has no effect. GUI applications based on QApplication exit normally with code 0 however.

I am using:

Qt 5.2.0 with Qt Creator 3.0.0 32-bit and MingW 4.8 32-bit (all ‘fresh out of the box’) in Windows 8.1 64-bit.

Thank you for your help!

Понравилась статья? Поделить с друзьями:

Не пропустите эти материалы по теме:

  • Яндекс еда ошибка привязки карты
  • 1073740791 ошибка при майнинге
  • 1073548784 номер ошибки
  • 1072 код ошибки камаз
  • 1070 код ошибки

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

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