Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I came across an odd feature in Visual Studio 2012 today.

The symptom is that an executable was unable to find an exported function in one our DLLs. This code functions properly when built in VS 2008.

I finally determined the issue. The calling executable was looking for a virtual destructor for the class, but the class itself did not contain a virtual destructor. There is a mismatch in the name mangling between the dll and the caller.

Clearly the workaround is simple and straight forward. But it will take time to find all of the instances in our code where this manifests.

Is this a new requirement of 2012, or a bug?
Posted
Comments
Sergey Alexandrovich Kryukov 10-Jul-13 16:28pm    
A code sample could help to understand the issue...
—SA
JackDingler 10-Jul-13 16:47pm    
I may try a code sample this evening. Should be easy to reproduce.

I'm in the habit of making destructors virtual by default.
In this case I'm porting legacy code.
The_Inventor 11-Jul-13 2:32am    
MSW has been closing the security holes where it can find them. There was a big change in VS2012 from VS2008. VS is no exception. Not having a destructor, virtual or otherwise, in a .dll is bad if there is a class structure involved. It leaves fragments of memory open to abuse.
JackDingler 11-Jul-13 9:17am    
No there is a destructor.

The class definition says it's non-virtual. The exported function in the DLL is clearly marked as non-virtual.

But the calling application is looking for a virtual destructor and not finding it.

What surprised me is that it didn't produce a link time error. I'll check the lib file and see if it differs from the DLL.
JackDingler 11-Jul-13 10:36am    
I think I solved the mystery, what likely happened is that I had changed the class to a virtual, and then reverted the change, but the project make didn't update the library on the revert.

1 solution

Microsoft requires it. Read it for yourself: a little funny: "Note that these rules are the same for nonexportable classes."

http://msdn.microsoft.com/en-us/library/81h27t8c(v=vs.80).aspx[^]
 
Share this answer
 
Comments
JackDingler 15-Jul-13 14:00pm    
Thank you very much. My 5. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900