[Coin-discuss] CoinRowCut and Sbb problems in MSVS 6.0

Laszlo Ladanyi ladanyi at us.ibm.com
Fri Jun 20 07:58:32 EDT 2003


On Thu, 19 Jun 2003, Yan Xu wrote:

> When replace the number of allocated entries by numberToAdd+1, Sbb works 
> fine.
> 
> If try num=1, Q1 has no problem. But I still don't see why num=0 fails 
> for OsiRowCut while is fine for other data types.

One possible reason is that for built-in types (like char, int, double) the
delete[] operator knows that there is no need to call a destructor. However,
OsiRowCut is a user type with a defined destructor. My gut feeling is that
MSVS6.0 generates a code for delete[] that invokes the destructor of the
object type at least once, which leads to a crash if no object was created.

--Laci

PS: Alan's solution of commenting out the delete[] should work, too, but it
leads to a huge memory leak.

> 
> I checked my SbbModel.cpp status, it is up-to-date :-)
> 
> ===================================================================
> File: SbbModel.cpp      Status: Up-to-date
> 
>    Working revision:    1.31
>    Repository revision: 1.31    /usr/cvs/coin/COIN/Sbb/SbbModel.cpp,v
>    Sticky Tag:          (none)
>    Sticky Date:         (none)
>    Sticky Options:      (none)

Sorry, it was my mistake...

> 
> 
> Yan
> 

--Laci

> 
> 
> Laszlo Ladanyi wrote:
> 
> >Note that this is just guesswork since I do not use Windows.
> >
> >I sort of hesitate to say this, but this suspiciously looks like a compiler
> >bug... From your Q2 it seems that the generated code has no problems deleting
> >the array when more than 0 was allocated to start with and crashes when 0 cuts
> >are allocated. An easy way to test this would be to replace the number of
> >allocated entries by num+1. If that helps then it's almost certainly a
> >compiler bug. Did you try your Q1 with num=1 ?
> >
> >BTW, when did you download SBB? In the current version there is no 
> >'delete [] addCuts;' anywhere near line 1880 :-).
> >
> >--Laci
> >
> >On Thu, 19 Jun 2003, Yan Xu wrote:
> >
> >  
> >
> >>Hi, I encounted some problems when using Sbb in Windows, compiler is MSVS6.0
> >>
> >>Question 1: Why following code crashes when delete [] A, but declaring A 
> >>as many other types (I tried int, char, ..., and some user-defined 
> >>class) is fine? Is there a problem in OsiRowCut ?
> >>
> >>#include <iostream>
> >>#include "OsiRowCut.hpp"
> >>using namespace std;
> >>
> >>int main()
> >>{
> >>    int num = 0;
> >>
> >>    OsiRowCut* A = new OsiRowCut [num];
> >>//  int* A = new int [num];                          // OTHER TYPE IS FINE
> >>
> >>    cout << "num = " << num << endl;
> >>    delete [] A;                                            // CRASH HERE
> >>    return 0;
> >>}
> >>
> >>
> >>Question 2:  When running Sbb with input data file: fiber, dcmutli, it 
> >>crashes. The place cause crash is line 1880 of SbbModel.cpp
> >>
> >>                    delete [] addCuts;
> >>
> >>After  print numberToAdd, something like:
> >>.......
> >>numberToAdd = 15
> >>numberToAdd = 25
> >>numberToAdd = 6
> >>numberToAdd = 3
> >>numberToAdd = 4
> >>numberToAdd = 5
> >>numberToAdd = 0  // CRASH AFTER THIS LINE
> >>
> >>I found when numberToAdd is 0, 'delete' crashes, which brings the first 
> >>question.
> >>
> >>Anyone have some idea, thanks. By the way, I don't have these problems 
> >>in my Linux machine.
> >>
> >>Yan
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>_______________________________________________
> >>Coin-discuss mailing list
> >>Coin-discuss at www-124.ibm.com
> >>http://www-124.ibm.com/developerworks/oss/mailman/listinfo/coin-discuss
> >>
> >>    
> >>
> >
> >_______________________________________________
> >Coin-discuss mailing list
> >Coin-discuss at www-124.ibm.com
> >http://www-124.ibm.com/developerworks/oss/mailman/listinfo/coin-discuss
> >  
> >
> 
> 
> -- 
> Yan Xu
> PhD Student                                     | Tel:   610-758-4042
> Department of Instrial and Systems Engineering  | Fax:   610-758-4886
> Lehigh University                               | Email: yax2 at lehigh.edu
> 
> 
> 





More information about the Coin-discuss mailing list