[gecode-users] Crash while freeing memory in connection with VS2010

Alexander Kleff alexander.kleff at ptv.de
Thu Jan 20 16:26:41 CET 2011


Hi,

update: I built Gecode binaries myself with VS2010 and the test application works fine...
What precisely are you going to fix for 3.4.3? I'm not sure if I got you right.

Best,
Alexander


Von: Christian Schulte [mailto:cschulte at kth.se]
Gesendet: Donnerstag, 20. Januar 2011 12:18
An: Alexander Kleff; 'Mikael Zayenz Lagerkvist'
Cc: users at gecode.org
Betreff: RE: [gecode-users] Crash while freeing memory in connection with VS2010

I came to the same conclusion and this is already a problem if you do not mix versions: allocation and deallocation must always be done by the same DLL, this is a known bug in Windows. I'll fix that for 3.4.3.

We do not use project files but Makefiles with Cygwin, check MPG for details.

Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/

From: Alexander Kleff [mailto:alexander.kleff at ptv.de]
Sent: Thursday, January 20, 2011 12:15 PM
To: cschulte at kth.se; 'Mikael Zayenz Lagerkvist'
Cc: users at gecode.org
Subject: AW: [gecode-users] Crash while freeing memory in connection with VS2010

Hi,

after some research I came to the following conclusion:
Due to inlining, the memory of the node in LinExpr will be allocated by msvcr100d.dll, whilst at least the destructor of LinExpr is not inlined. The memory of the node will therefore be freed by msvcr90d.dll. This will not work.
As I see it, there is no other way for me than to have Gecode bound to msvcr100d.dll. Can you help me out by making your VS2008 project files available? This way, it would be much easier to migrate to VS2010 than to start from scratch.

Cheers,
Alexander



Von: users-bounces at gecode.org [mailto:users-bounces at gecode.org] Im Auftrag von Alexander Kleff
Gesendet: Donnerstag, 20. Januar 2011 10:43
An: cschulte at kth.se; 'Mikael Zayenz Lagerkvist'
Cc: users at gecode.org
Betreff: Re: [gecode-users] Crash while freeing memory in connection with VS2010

Hi,

I made another project (currently for x86 platform) to make sure it is unmanaged. Unfortunately, the problem still arises, although I cannot see anything suspicious. Any other idea?
I'm using the 3.4.2 binaries from your site, so both msvcr90d.dll and msvcr100d.dll are currently loaded.

Thanks for any suggestion,
Alexander

Von: Christian Schulte [mailto:cschulte at kth.se]
Gesendet: Donnerstag, 20. Januar 2011 09:03
An: 'Mikael Zayenz Lagerkvist'; Alexander Kleff
Cc: users at gecode.org
Betreff: RE: [gecode-users] Crash while freeing memory in connection with VS2010

Please,

also let us know which platform (x86 versus x64) and whether you use the binaries we distribute or have build them yourselves (then we need to know whether you built with 2008 or 2010)

Thanks
Christian

--
Christian Schulte, www.ict.kth.se/~cschulte/

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf Of Mikael Zayenz Lagerkvist
Sent: Wednesday, January 19, 2011 8:46 PM
To: Alexander Kleff
Cc: users at gecode.org
Subject: Re: [gecode-users] Crash while freeing memory in connection with VS2010

Hi,

You seem to be using managed C++. Have you tried running your program with standard C++? The different memory policy might be a source of problems.

I don't have a Windows machine to test on, so I haven't tried your program myself.

Cheers,
Mikael
2011/1/19 Alexander Kleff <alexander.kleff at ptv.de<mailto:alexander.kleff at ptv.de>>
Hi once again,

the code below compiles and links in both versions (so I assume I did not make an all too obvious modeling mistake) but it crashes in VS2010 in contrast to VS2008(Express).
The error seems to occur during the destruction of the linear expression. The debugger sets the break point to Heap::rfree(void* p) in heap.hpp in all three cases.
Can you reproduce it?

Thanks for help,
Alexander



#include <gecode/minimodel.hh>

using namespace Gecode;

class GecodeTest : public Space {
public:
  GecodeTest(void)
  {
   IntVar z(*this, 0, 1);

   IntVar e1 = expr(*this, 1 * z);
   IntVar e2 = expr(*this, z);      // error 1

   IntArgs cost(2);
   for (int v=0; v<2; ++v)
   {
      cost[v] = v;
   }

   LinExpr xy = element(cost, z);
   IntVar e3 = expr(*this, xy);
   IntVar e4 = expr(*this, element(cost, z));   // error 2
  } // error 3 (in destructor)


  GecodeTest(bool share, GecodeTest& s) : Space(share, s) {}
  virtual Space* copy(bool share) { return new GecodeTest(share,*this); }
};


// main function
int main(array<System::String ^> ^args)
{
  GecodeTest* m = new GecodeTest;
  delete m;
  return 0;
}


_______________________________________________
Gecode users mailing list
users at gecode.org<mailto:users at gecode.org>
https://www.gecode.org/mailman/listinfo/gecode-users



--
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20110120/ee3d9caf/attachment-0001.htm>


More information about the users mailing list