4

I have a post-processing program that interfaces with Abaqus. The program works fine with Abaqus 6.9 EF1. I want to update the program to work with Abaqus 6.12. I have not had any luck with getting the program to work with the updated API.

I have updated the list of libraries to link with in Visual Studio 2010. Everything builds and links properly. When I run the program, I get the following message before hitting main:

Error message

Since the program is big (>120k lines), I decided to go back to basics. The simple program below runs fine until I call delete. Once I call delete, I get the same error message. If I do not link to the Abaqus libraries, the program completely runs.

#include <iostream>

int main( int argc, char* argv[] )
{
    std::cout << "Hello world" << std::endl;

    int *p;
    p = new int(3);
    std::cout << *p << std::endl;
    delete p;

    return 0;
}

To Clarify:

Case 1: Not linking to Abaqus libraries. Runs fine.

Case 2: Linking to Abaqus libraries. Throws Debug Assertion Failed message.

Bottom line: I do not understand how linking but not using their libraries breaks the simple program.

In my previous problems with Abaqus, I have convinced myself that they have created their own new and delete operators. Could their version of new be called while the standard version of delete is called? If so, it their a way to resolve the scope of these functions?

Derek
  • 1,104
  • 13
  • 35
  • 1
    Try `::new` and `::delete` and see what it does. – Mahesh Jun 21 '13 at 16:51
  • The error being in `dbgdel.cpp` certainly suggests that the problem is occurring in `operator delete`, and the path seems to point to the Microsoft version. Try stepping with the debugger into the `new` and see where it goes. – Pete Becker Jun 21 '13 at 16:59
  • @Mahesh Thank you for your suggestion. I get the same results using `::new` and `::delete`. If there are two new functions in the global namespace, do I have any options? I'll dig around in the API to see if there actually is a `new` function defined by Abaqus. – Derek Jun 21 '13 at 17:04
  • @PeteBecker I have tried stepping into the `new` function, but Visual Studio jumps over it. – Derek Jun 21 '13 at 17:05
  • I was afraid of that. It's been several years since I used Microsoft tools, but there **is** a tool that you can run on your executable to see what external symbols it links to (it might be `objdump`, but I'm not at all confident of that). Find `operator new` and `operator delete` and see which DLL they're coming from. If they're in two different DLLs that's probably the source of the problem. – Pete Becker Jun 21 '13 at 17:08
  • I can confirm that Abaqus defines `new` and `delete` operators. In fact, they have at least two different sets. One set is for larger classes and the other set is for smaller classes. I don't see that they have wrapped them in a namespace. – Derek Jun 21 '13 at 17:11
  • Although, their `new` and `delete` operators are kept within a class, so they shouldn't hide the `::new` and `::delete` operators. – Derek Jun 21 '13 at 17:26
  • *linking but not using* - are you sure about this? I mean, if you create new project, do not include **any** Abaqus header, just add Abaqus library as the last library to link against in Linker options - will there be the same problem? – izogfif Jun 24 '13 at 06:39
  • @izogfif Yes, I'm sure about it. Also, I was able to verify that the call to `operator new` is linked to an Abaqus .dll. This explains my problem. I tried switching the order, but I'm not sure it matters. – Derek Jun 24 '13 at 21:12

1 Answers1

0

It turns out that Abaqus defines their own operator new and operator delete in the global namespace. Thus, I was unknowingly linking to their implementation of operator new.

However, Visual Studio is linking to the Abaqus definition of operator new and not to the Abaqus definition of operator delete. Instead, Visual Studio is linking to the standard definition of operator delete.

These functions cannot be used interchangably, so I receive the error message. However, because Abaqus placed their operator new and operator delete functions in the global namespace, I believe that I have no control over which function gets linked.


Update: The above is only partially correct. Abaqus does define their own operator new but they do not define a matching operator delete -- at least in the global namespace.

Thus, Visual Studio cannot link to the corresponding Abaqus operator delete because it does not exist.

Derek
  • 1,104
  • 13
  • 35