Hi Brad, I think this change is a bit cleaner and an acceptable, albeit with a bit cringe about how hacky windows programming is and the fallout it has on the rest of the programming world. You changes are now merged and submitted to svn/trunk.
Cheers, Robert. On Thu, Oct 14, 2010 at 11:41 AM, Christiansen, Brad <[email protected]> wrote: > Hi Robert, > > I have done some more reading and I understand a little what is going on. > With this understanding I have made the same fix but without defining any > additional macros (though I do use the already defined GL_APIENTRY). The > change to tess.h also removes the special case for windows as this is handled > already by using the existing GL_APIENTRY. > > The cause of the problem is the fact the OSG is built using the _cdecl > calling convention (which is normal). However if you're using any callback > functions with the Windows API (which the GLU implementation does), they must > be declared using CALLBACK and/or WINAPI. That will apply appropriate > decorations to make the compiler generate code that cleans the stack > correctly. On Windows with visual sutio GL_APIENTRY ends up being defined as > WINAPI. > > Let me know if you are happy with the new approach. > > Cheers, > > Brad > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Robert > Osfield > Sent: Thursday, 14 October 2010 3:58 PM > To: OpenSceneGraph Submissions > Subject: Re: [osg-submissions] [osg-users] Crash with SVN version of > Tessellator (FIXED) > > Hi Brad, > > I would really like to keep the macro crud down in the headers, there > is already the OSG_EXPORT macro used, this is purely to placate > Windows issues, but to have yet another macro placed in a function > call really is forcing the readability to deteriorate further. Can > this be avoided? We declare other functions in the OSG without > anything more than the OSG_EXPORT. > > The implementation side I'm a little less concerned about, as it > already has these macros in place, but they don't have the extra > OSG_EXPORT. > > Robert. > > > On Thu, Oct 14, 2010 at 5:24 AM, Christiansen, Brad > <[email protected]> wrote: >> Hi, >> >> I have managed to track down the issue and have attached the fix. The >> problem was that the GLU functions were using a different calling >> convention. I don't for a second pretend to understand the issue properly or >> why it exists as anything that combines windows and C++ completely defies my >> understanding. However, what I have done seems reasonable and does fix the >> problem. Somebody who actually understands this stuff might have a cleaner >> solution but the changes are actually very small and seem inline with what >> has been done in other parts of OSG. >> >> For anyone who is interested or might understand the errors better, the >> Visual Studio debugger reported the following: >>>> Run-Time Check Failure #0 - The value of ESP was not properly saved across >>>> a function call. This is usually a result of calling a function declared >>>> with one calling convention with a function pointer declared with a >>>> different calling convention. >> >> This led me here: >> http://blogs.msdn.com/b/mithuns/archive/2006/12/11/pay-attention-to-the-calling-convention.aspx >> Which is what I based my fix on. >> >> >> >> I have also noticed some warning during compilation which I haven't fixed >> but thought I would mention anyway: >> >> 1> tess.cpp >> 1>..\..\..\src-trunk\src\osg\glu\libtess\tess.cpp(505): warning C4611: >> interaction between '_setjmp' and C++ object destruction is non-portable >> >> 1> error.cpp >> 1>..\..\..\src-trunk\src\osg\glu\libutil\error.cpp(135): warning C4245: >> 'initializing' : conversion from 'int' to 'GLuint', signed/unsigned mismatch >> >> 1> tess.cpp >> 1>..\..\..\src-trunk\src\osg\glu\libtess\tess.cpp(505): warning C4611: >> interaction between '_setjmp' and C++ object destruction is non-portable >> >> 1>d:\osg\osg-trunk\src-trunk\src\osg\glu\libutil\mipmap.cpp(5208): warning >> C4701: potentially uninitialized local variable 'iter' used >> 1>d:\osg\osg-trunk\src-trunk\src\osg\glu\libutil\mipmap.cpp(5550): warning >> C4701: potentially uninitialized local variable 'iter' used >> 1>d:\osg\osg-trunk\src-trunk\src\osg\glu\libutil\mipmap.cpp(6934): warning >> C4701: potentially uninitialized local variable 'iter' used >> 1>d:\osg\osg-trunk\src-trunk\src\osg\glu\libutil\mipmap.cpp(7368): warning >> C4701: potentially uninitialized local variable 'iter' used >> >> Cheers. >> Brad >> >> >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On Behalf Of >> Christiansen, Brad >> Sent: Thursday, 14 October 2010 9:40 AM >> To: OpenSceneGraph Users >> Subject: Re: [osg-users] Crash with SVN version of Tessellator >> >> Hi Robert, >> >> Both osgtesselate and osgtext3D crash as well. The stack trace for >> osgtesselate is: >> >>> osgd.dll!RenderStrip(osg::GLUtesselator * tess=0x0272a9f8, GLUhalfEdge * >>> e=0x0272e6a0, long size=12907152) Line 311 + 0x32 bytes C++ >> osgd.dll!__gl_renderMesh(osg::GLUtesselator * tess=0x0272a9f8, GLUmesh * >> mesh=0x0272bb40) Line 99 + 0xd bytes C++ >> osgd.dll!osg::gluTessEndPolygon(osg::GLUtesselator * tess=0x0272a9f8) >> Line 572 + 0xd bytes C++ >> osgUtild.dll!osgUtil::Tessellator::endTessellation() Line 87 + 0xf >> bytes C++ >> osgUtild.dll!osgUtil::Tessellator::retessellatePolygons(osg::Geometry & >> geom={...}) Line 285 C++ >> osgtessellated.exe!makeFrontWall(const float zpos=0.00000000) Line 289 >> + 0x19 bytes C++ >> osgtessellated.exe!makeHouse() Line 295 + 0xb bytes C++ >> osgtessellated.exe!makeTessellateExample() Line 563 + 0x5 bytes C++ >> osgtessellated.exe!main(int argc=1, char * * argv=0x0270dbe8) Line 762 >> + 0x5 bytes C++ >> osgtessellated.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C >> osgtessellated.exe!mainCRTStartup() Line 371 C >> >> Now I have a nice simple example to debug (and a debug build of it) I will >> try and dig a little further and track down the issue. I am not holding my >> breath though as my C++ debugging skills are not exactly stellar. I am >> primarily a Java programmer after all : ) >> >> I assume this is a platform specific issue of some type? It would be great >> to get some feedback from others using different platforms and compilers to >> try and narrow down the cause of the crash. >> >> Cheers, >> >> Brad >> >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On Behalf Of Robert >> Osfield >> Sent: Wednesday, 13 October 2010 4:54 PM >> To: OpenSceneGraph Users >> Subject: Re: [osg-users] Crash with SVN version of Tessellator >> >> Hi Brad, >> >> As you've spotted the GLU tessellation code has now been integrated >> with the build of the core OSG library. I have taken the code from >> Mesa 7.9, which in turn based it's GLU implementation on SGI base. >> I'd expect most GLU implementations are based on the original SGI code >> base, they might all have different bug fixes applied to them, perhaps >> the Mesa code doesn't have a fix that the previous GLU library that >> you were linking against had, or perhaps I've introduced a bug during >> integration. >> >> One advantage now is that you will be able build the GLU code with >> debug along with the rest of the OSG and be able step through it see >> where problems might be arising. From your stack trace the line: >> >> :push_back(osg::Vec3f * const & _Val=0x00000000) >> >> Looks pretty suspicious. The debug info doesn't really reveal exactly >> which code is calling phs_back with the dodgy value. >> >> BTW, Do you see problems when you run osgtext3D? Or osgtessellate? >> Both of these will be using the newly integrated GLU tessellation >> code. >> >> Robert. >> >> >> On Wed, Oct 13, 2010 at 9:42 AM, Christiansen, Brad >> <[email protected]> wrote: >>> Hi, >>> >>> I forgot a few details. I am runnign Windows 7 with Visual Studio 2010. >>> >>> The relevent bit of the stack trace is: >>> >>> msvcr100.dll!free(void * pBlock=0x0c3acde8) Line 51 C >>>> osgUtilrd.dll!std::vector<osg::Vec3f *,std::allocator<osg::Vec3f *> >>>> >::reserve(unsigned int _Count=141) Line 765 + 0x6 bytes C++ >>> osgUtilrd.dll!std::vector<osg::Vec3f *,std::allocator<osg::Vec3f *> >>> >::_Reserve(unsigned int _Count=150271084) Line 1297 + 0x21 bytes C++ >>> osgUtilrd.dll!std::vector<osg::Vec3f *,std::allocator<osg::Vec3f *> >>> >::push_back(osg::Vec3f * const & _Val=0x00000000) Line 995 + 0xe bytes >>> C++ >>> 08f4f488() >>> osgrd.dll!__gl_renderCache(osg::GLUtesselator * tess=0x08f4f9b4) >>> Line 493 + 0x1a bytes C++ >>> >>> Cheers, >>> >>> Brad >>> >>> -----Original Message----- >>> From: [email protected] >>> [mailto:[email protected]] On Behalf Of >>> Christiansen, Brad >>> Sent: Wednesday, 13 October 2010 2:05 PM >>> To: OpenSceneGraph Users >>> Subject: [osg-users] Crash with SVN version of Tessellator >>> >>> Hi, >>> >>> I have just updated to the latest revision of OSG and am now getting a >>> crash when calling Tessellator.retessellatePolygons. >>> >>> The code in my application calling this function hasn't changed in many >>> years and has started breaking since the update. I have debugged the issue >>> a little and the crash is occuring when the Tessellator::endTessellation >>> function is called. The crash occurs on a call to free. I think I will need >>> to do a full debug build of OSG to get much further with my debuging (I am >>> using release with debug info) but a full rebuild will take me a while. >>> >>> The previous (working) version of OSG I used was revision 11703 and the new >>> (broken) revision is 11835. >>> >>> I know al the new GLU code has been added between these revision so I am >>> guessing that is what is causing the error. Before I go much further I was >>> wondering if anyone had any info that might help me track down the issue. >>> It doesn't seem that the required usage of Tessellator has changed but I am >>> hoping it has so I can simply call some different methods to fix the issue. >>> >>> Cheers, >>> >>> Brad >>> >>> >>> >>> >>> >>> DISCLAIMER:--------------------------------------------------------------------------- >>> This e-mail transmission and any documents, files and previous e-mail >>> messages >>> attached to it are private and confidential. They may contain proprietary >>> or copyright >>> material or information that is subject to legal professional privilege. >>> They are for >>> the use of the intended recipient only. Any unauthorised viewing, use, >>> disclosure, >>> copying, alteration, storage or distribution of, or reliance on, this >>> message is >>> strictly prohibited. No part may be reproduced, adapted or transmitted >>> without the >>> written permission of the owner. If you have received this transmission in >>> error, or >>> are not an authorised recipient, please immediately notify the sender by >>> return email, >>> delete this message and all copies from your e-mail system, and destroy any >>> printed >>> copies. Receipt by anyone other than the intended recipient should not be >>> deemed a >>> waiver of any privilege or protection. Thales Australia does not warrant or >>> represent >>> that this e-mail or any documents, files and previous e-mail messages >>> attached are >>> error or virus free. >>> -------------------------------------------------------------------------------------- >>> >>> _______________________________________________ >>> osg-users mailing list >>> [email protected] >>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>> >>> >>> >>> DISCLAIMER:--------------------------------------------------------------------------- >>> This e-mail transmission and any documents, files and previous e-mail >>> messages >>> attached to it are private and confidential. They may contain proprietary >>> or copyright >>> material or information that is subject to legal professional privilege. >>> They are for >>> the use of the intended recipient only. Any unauthorised viewing, use, >>> disclosure, >>> copying, alteration, storage or distribution of, or reliance on, this >>> message is >>> strictly prohibited. No part may be reproduced, adapted or transmitted >>> without the >>> written permission of the owner. If you have received this transmission in >>> error, or >>> are not an authorised recipient, please immediately notify the sender by >>> return email, >>> delete this message and all copies from your e-mail system, and destroy any >>> printed >>> copies. Receipt by anyone other than the intended recipient should not be >>> deemed a >>> waiver of any privilege or protection. Thales Australia does not warrant or >>> represent >>> that this e-mail or any documents, files and previous e-mail messages >>> attached are >>> error or virus free. >>> -------------------------------------------------------------------------------------- >>> >>> _______________________________________________ >>> osg-users mailing list >>> [email protected] >>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>> >> _______________________________________________ >> osg-users mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >> >> >> DISCLAIMER:--------------------------------------------------------------------------- >> This e-mail transmission and any documents, files and previous e-mail >> messages >> attached to it are private and confidential. They may contain proprietary or >> copyright >> material or information that is subject to legal professional privilege. >> They are for >> the use of the intended recipient only. Any unauthorised viewing, use, >> disclosure, >> copying, alteration, storage or distribution of, or reliance on, this >> message is >> strictly prohibited. No part may be reproduced, adapted or transmitted >> without the >> written permission of the owner. If you have received this transmission in >> error, or >> are not an authorised recipient, please immediately notify the sender by >> return email, >> delete this message and all copies from your e-mail system, and destroy any >> printed >> copies. Receipt by anyone other than the intended recipient should not be >> deemed a >> waiver of any privilege or protection. Thales Australia does not warrant or >> represent >> that this e-mail or any documents, files and previous e-mail messages >> attached are >> error or virus free. >> -------------------------------------------------------------------------------------- >> >> _______________________________________________ >> osg-users mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >> >> >> DISCLAIMER:--------------------------------------------------------------------------- >> This e-mail transmission and any documents, files and previous e-mail >> messages >> attached to it are private and confidential. They may contain proprietary or >> copyright >> material or information that is subject to legal professional privilege. >> They are for >> the use of the intended recipient only. Any unauthorised viewing, use, >> disclosure, >> copying, alteration, storage or distribution of, or reliance on, this >> message is >> strictly prohibited. No part may be reproduced, adapted or transmitted >> without the >> written permission of the owner. If you have received this transmission in >> error, or >> are not an authorised recipient, please immediately notify the sender by >> return email, >> delete this message and all copies from your e-mail system, and destroy any >> printed >> copies. Receipt by anyone other than the intended recipient should not be >> deemed a >> waiver of any privilege or protection. Thales Australia does not warrant or >> represent >> that this e-mail or any documents, files and previous e-mail messages >> attached are >> error or virus free. >> -------------------------------------------------------------------------------------- >> >> >> _______________________________________________ >> osg-submissions mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >> >> > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > > > DISCLAIMER:--------------------------------------------------------------------------- > This e-mail transmission and any documents, files and previous e-mail messages > attached to it are private and confidential. They may contain proprietary or > copyright > material or information that is subject to legal professional privilege. They > are for > the use of the intended recipient only. Any unauthorised viewing, use, > disclosure, > copying, alteration, storage or distribution of, or reliance on, this message > is > strictly prohibited. No part may be reproduced, adapted or transmitted > without the > written permission of the owner. If you have received this transmission in > error, or > are not an authorised recipient, please immediately notify the sender by > return email, > delete this message and all copies from your e-mail system, and destroy any > printed > copies. Receipt by anyone other than the intended recipient should not be > deemed a > waiver of any privilege or protection. Thales Australia does not warrant or > represent > that this e-mail or any documents, files and previous e-mail messages > attached are > error or virus free. > -------------------------------------------------------------------------------------- > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

