Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Access violation in Release only

    SDK Help
    0
    16
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 11/06/2014 at 09:49, xxxxxxxx wrote:

      Originally posted by xxxxxxxx

      Using a matrix pointer instead of the object itself solved the problem for me.
      [...]

      That basically points either to a compiler bug (related to inlining your code) or (not so likely) a problem caused by excessive stack usage in the surrounding code - you can check the later by using the analyzer function of VS 2012; it will tell you if methods stack usage exceeds 16 kb (and how much it needs exactly) - although that doesn't catch problems caused by recursive calls using slightly less than 16 kb stack.

      Best regards,

      Wilfried

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 12/06/2014 at 02:40, xxxxxxxx wrote:

        Thanks for that experty answer. I'm pretty sure not using so much stack space. I'm working with VS 2010. The previous version of my plugin was compiled with VS 2005 and this problem hasn't occured. So maybe it's really a compiler bug of VS 2010. I'll keep this issue in mind when updating VS.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 12/06/2014 at 05:55, xxxxxxxx wrote:

          May be important question is how do you call this function ?

          > So maybe it's really a compiler bug of VS 2010.
          Of course VS 2010 compiler is not the best one but usually compiler bugs are hidden in more exotic code fragments.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 12/06/2014 at 07:10, xxxxxxxx wrote:

            how do you call this function

            Not sure what you mean. It's not called recursive. It's just that simple service function called from different major functions, that build up some data structures.

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 13/06/2014 at 03:09, xxxxxxxx wrote:

              I mean do you call it like this ? 🙂

                
              Matrix m;  
              Matrix mp = Get_PointMatrix(&m, pcnt, index, up);  
              
              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 13/06/2014 at 03:34, xxxxxxxx wrote:

                No. The old version at the top of the page didn't need the pointer.

                OLD:

                Matrix m = Get_PointMatrix(pAdr, pcnt, index up);
                

                NEW:

                Matrix m;   
                Get_PointMatrix(&m;, pAdr, pcnt, index up);
                
                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 13/06/2014 at 07:48, xxxxxxxx wrote:

                  Why not use something like this then?
                  I think it is better to use reference as pointer.

                    
                      
                      
                      	Matrix m;
                      	Get_PointMatrix(m, pAdr, pcnt, index, up);
                  
                    
                      
                      
                      inline void Get_PointMatrix(Matrix &pMat, Vector pAdr[], LONG pcnt, LONG index,const Vector &up) 
                      {
                      	if(pAdr==nullptr) return;
                      	Vector p1, p2; 
                       
                      	pMat.off = pAdr[index]; 
                       
                      	if (index < pcnt - 1) p2 = pAdr[index+1]; 
                      	else p2 = pAdr[0]; 
                       
                      	if (index > 0) p1 = pAdr[index-1]; 
                      	else p1 = pAdr[pcnt-1]; 
                       
                      	pMat.v3 = !(p2 - p1); 
                      	pMat.v2 = up; 
                      	pMat.v1 = -(pMat.v3 % pMat.v2); 
                      }
                  
                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 13/06/2014 at 07:56, xxxxxxxx wrote:

                    Why? I prefer pointers. In your code, it's hard to distinguish references from objects.

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 13/06/2014 at 09:18, xxxxxxxx wrote:

                      May be because references are more restricted and this way more safe?
                      On can call the function with pointer as a return parameter in a couple of different ways.
                      Like this.

                        
                      Get_PointMatrix(nullptr, pAdr, pcnt, index, up);  
                      

                      in function like this but with Vector as first parameter, just swap two parameters and you get the problems.

                        
                      Get_PointMatrix(pAdr, &m, pcnt, index, up);  
                      

                      Of course this is off-topic now, and of course is "Geschmackssache" 🙂

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 13/06/2014 at 09:48, xxxxxxxx wrote:

                        And of course you always test the pointers to be not nullptr !?

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post