Hi Andreas

On 4/16/07, Andreas Goebel <[EMAIL PROTECTED]> wrote:

Hi,

the problem was the std::vector copy-constructor. I am probably still
having problems with different c-runtimes somewhere, though I carefully
tried to avoid this.

[...]

Though the reference is better code at this place anyway I wonder how I
can get rid of those c-runtime problems.

For those who don´t know about this: If you are using different
c-runtimes (msvcrt.dll and libcmt.dll for instance) then
memory-management doesn´t work between the dlls. In this case the memory
was allocated in osgUtil, and the std::vector copy-constructor tried to
reuse it. Thus it had to be deallocated in my program (as I took a
copy), which made it crash, probably because osgUtil used msvcrt.dll for
the allocation and I used libcmt.dll for the deallocation (or vice
versa), I´ll dig into this.

Am I right in assuming that the whole osg is linking against libcmt
(multi threaded c-runtime), or is this wrong?


It's wrong
The OSG links against the DLL version of the CRT which is msvcrt.lib (and
needs msvcrt.dll at runtime). Libcmt is the static version of the
multi-threaded runtime (libc.lib the static single-threaded) and should not
be used. I don't know why Microsoft continues to ship the static versions
because of the problems you mentioned: two executables/DLLs should always
link against the same CRT to avoid binary compatibility issues. To solve the
problem altogether the paradigm used in the OSG and other libs is to
systematically link against msvcrt.lib (Project config -> C/C++ -> Code
generation -> Multi-threaded DLL). Hopefully this is now the default in VS 8
but you have to change this for projects created in VS 6 and 7(1).

Regards

Thibault


Regards,

Andreas

Robert Osfield schrieb:
> Hi Andreas,
>
> Try adding adding LineSegmentIntersector::Intersection copy
> constructor, assignment operator and destructor to see if this has any
> effect, perhaps MSVC isn't creating these appropriately.
>
> Robert.
>
> On 4/16/07, Andreas Goebel <[EMAIL PROTECTED]> wrote:
>> Andreas Goebel schrieb:
>> >
>> >> MSVC allows you to generate debug info even in Release Mode; make
>> sure
>> >> you set the Debug Information Format in the C++ project options, and
>> >> tell the Linker to generate Debugging output. That might produce
more
>> >> useful information when you run in the debugger.
>> >>
>> >> HTH,
>> >>
>> >
>> > Thanks,
>> >
>> > that´s a good idea. Actually the program crashes here:
>> >
>> > MyIntersections.clear();
>> >        if (LineIntersector.containsIntersections() ){
>> >            osgUtil::LineSegmentIntersector::Intersections MyInts =
>> > LineIntersector.getIntersections();
>> >            for
>> > (osgUtil::LineSegmentIntersector::Intersections::iterator it =
>> > MyInts.begin();
>> >                it != MyInts.end(); ++it)
>> >
>> > MyIntersections.push_back(it->getWorldIntersectPoint() );
>> >
>> >
>> SetPosition(LineIntersector.getFirstIntersection
().getWorldIntersectPoint()
>>
>> > );
>> >        } //Here is the crash
>> >        else
>> >            SetPosition(osg::Vec3(0, 0, 0) );
>> >
>> > in the destructor of osgUtil::LineSegmentIntersector::Intersection
>> > (the crash is where the Intersections - vector goes out of scope).
>> >
>> > I´ll have a look at that destructor, but maybe Robert has an idea
>> > about that, too.
>> Aha, there is no desctructor, it´s just a simple struct. HM.
>>
>> Here is the call-sequenze of that crash:
>>
>>      ntdll.dll!7c911230()
>>      [Unten angegebene Rahmen sind möglicherweise nicht korrekt
und/oder
>> fehlen, keine Symbole geladen für ntdll.dll]
>>      ntdll.dll!7c97c943()
>>      ntdll.dll!7c97cd80()
>>      ntdll.dll!7c97df66()
>>      ntdll.dll!7c92056d()
>>      msvcr80.dll!78134b9f()
>>      msvcr80.dll!78134bbe()
>>      ntdll.dll!7c95a5d0()
>>      osgUtil.dll!009db7c7()
>>      ntdll.dll!7c9368ad()
>>      DreiDEdit.exe!memmove_s(void * dst=0x01574288, unsigned int
>> sizeInBytes=24, const void * src=0x018b6e40, unsigned int count=24)
>> Zeile 58 + 0xc Bytes    C
>>      DreiDEdit.exe!std::_Uninit_copy<double const *,double
>> *,std::allocator<double> >(const double * _First=0x018b6e40, const
>> double * _Last=0x018b6e58, double * _Dest=0x014f0000,
>> std::allocator<double> & __formal={...}, std::allocator<double> &
>> __formal={...}, std::allocator<double> & __formal={...})  Zeile 129 +
>> 0xc Bytes    C++
>>
>> DreiDEdit.exe!stdext::unchecked_uninitialized_copy
<std::_Vector_const_iterator<double,std::allocator<double>
>>
>>  >,double *,std::allocator<double>
>>  >(std::_Vector_const_iterator<double,std::allocator<double> >
>> _First=0.45205613970756531,
>> std::_Vector_const_iterator<double,std::allocator<double> >
>> _Last=6.9850276205963215e+107, double * _Dest=0x7c936ac8,
>> std::allocator<double> & _Al={...})  Zeile 674 + 0x1d Bytes    C++
>>      DreiDEdit.exe!std::vector<double,std::allocator<double>
>>  >::_Ucopy<std::_Vector_const_iterator<double,std::allocator<double> >
>>  >(std::_Vector_const_iterator<double,std::allocator<double> >
>> _First={...}, std::_Vector_const_iterator<double,std::allocator<double>
>>  > _Last=3.785200942584e-317#DEN, double * _Ptr=0x018b6c08)  Zeile 1105
>> + 0x15 Bytes    C++
>>      ntdll.dll!7c9368ad()
>>      ntdll.dll!7c9206eb()
>>      msvcr80.dll!78134ce9()
>>      msvcr80.dll!7817ff7a()
>>      osgUtil.dll!009d8df9()
>>      osgUtil.dll!009d90d2()
>>      DreiDEdit.exe!free(void * pBlock=0x018b6c08)  Zeile 110    C
>>      DreiDEdit.exe!std::vector<double,std::allocator<double> >::_Tidy()
>> Zeile 1096 + 0x6 Bytes    C++
>>
>>
DreiDEdit.exe!osgUtil::LineSegmentIntersector::Intersection::~Intersection
()
>>
>> + 0x20 Bytes    C++
>>  >    DreiDEdit.exe!GeoPoint::Realize()  Zeile 78    C++
>>
>>
>> Looks like a strange problem.
>>
>> Regards,
>>
>> Andreas
>> >
>> > Regards,
>> >
>> > Andreas
>> >
>> > _______________________________________________
>> > osg-users mailing list
>> > [email protected]
>> > http://openscenegraph.net/mailman/listinfo/osg-users
>> > http://www.openscenegraph.org/
>> >
>> >
>>
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://openscenegraph.net/mailman/listinfo/osg-users
>> http://www.openscenegraph.org/
>>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
>


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to