-1

I am adding ACE / TAO as a component to a large project which is written in C and C++. I received an .IOR file from the server, and I use the .IOR file when calling CORBA::ORB_init(argc, argv)

I constructed my own argc and argv as followed

int argc = 2;
char *argv[2] = { 0 };
argv[0] = "-k";
argv[1] = "D:\\IOR\\test.ior";

CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

When I call ORB_init, I get a "Debug Assertion Failed!", and it points to C:\Program Files (x86)\Windows Kits\10\Source\10.0.17763.0\ucrt\heap\debug_heap.cpp line: 908

_ASSERTE(is_block_type_valid(header->_block_use));

CORBA::ORB_init was called very early in the code, so there isn't many things that can go wrong. Am I missing something obvious?

Lex L
  • 315
  • 1
  • 3
  • 17

1 Answers1

1
  • You got a heap corruption indicated by the assertion in debug_heap
    • when you run this in the debugger, you should see (Call Stack) where the assertion triggers, possibly enabling you to pinpoint the problem.

That being said, ORB_init(argc, argv) is supposed to get the C command line arguments and parse them. That means argc and argv should probably abide by the rules for these arguments:

argc An integer that contains the count of arguments that follow in argv. The argc parameter is always greater than or equal to 1.

argv An array of null-terminated strings representing command-line arguments entered by the user of the program. By convention, argv[0] is the command with which the program is invoked. argv[1] is the first command-line argument. The last argument from the command line is argv[argc - 1], and argv[argc] is always NULL.

Try:

int argc = 3;
char *argv[4];
argv[0] = "program";
argv[1] = "-k";
argv[2] = "D:\\IOR\\test.ior";
argv[3] = nullptr;
Martin Ba
  • 37,187
  • 33
  • 183
  • 337