<div><font><div style="font-family: "lucida Grande", Verdana;"><div>Hello, Henri Verbeet. Yes, it is at least greater than or equal to three, but it happens in the upper function d2d_path_geometry_triangulate(). Through some testing methods, I locate it before d2d_path_geometr_triangulate() calls d2d_cdt_triangulate(), it will change the value of vertex_count , Make it less than 3. When d2d_cdt_triangulate() is actually received, the value of vertex_count will cause a stack overflow error.</div><div>In d2d_path_geometry_triangulate(), the code block to change the size of vertex_count is as follows:</div><div><br></div><div>for (i = 1; i <vertex_count; ++i)</div><div>     {</div><div>         if (!memcmp(&vertices[i-1], &vertices[i], sizeof(*vertices)))</div><div>         {</div><div>             --vertex_count;</div><div>             memmove(&vertices[i], &vertices[i + 1], (vertex_count-i) * sizeof(*vertices));</div><div>             --i;</div><div>         }</div><div>     }</div><div><br></div><div>We can see that the value of vertex_count has been reduced. At the same time, we saw in the test that after passing in d2d_cdt_triangulate(), the vertex_count is less than 3.</div></div><div style="font-family: "lucida Grande", Verdana;"><includetail> </includetail></div><div style=""><includetail style=""><font face="lucida Grande, Verdana">Of course, under normal circumstances, it is difficult to test and find this problem. I found that it was a drawing application that I migrated. Whenever I draw with the pen, I click the mouse habitually, and the application gets stuck. The debug log throws a stack overflow error. By tracking this problem, I found it and found a solution to it, which is through this patch of mine.</font></includetail></div></font></div><div><includetail><div> </div><div> </div><div style="font:Verdana normal 14px;color:#000;"><div style="FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="FONT-SIZE: 12px;background:#efefef;padding:8px;"><div id="menu_sender"><b>From: </b> "Henri Verbeet"<hverbeet@gmail.com>;</div><div><b>Date: </b> Mon, Aug 30, 2021 01:09 PM</div><div><b>To: </b> "陈长胜"<chenchangsheng@uniontech.com>; <wbr></div><div><b>Cc: </b> "wine-devel"<wine-devel@winehq.org>; <wbr></div><div><b>Subject: </b> Re: [PATCH] d2d1: Fix the stack overflow error caused by d2d_cdt_triangulate().</div></div><div> </div><div style="position:relative;"><div id="tmpcontent_res"></div>On Mon, 30 Aug 2021 at 09:48, 陈长胜 <chenchangsheng@uniontech.com> wrote:<br>><br>> When vertex_count==1 or 0, d2d_cdt_triangulate will always be called by itself, causing stack overflow error.<br><br>How does it end up getting called like that, do you have a test?<br><br>If I had to guess, I suppose it's possible that we end up with less<br>than three vertices after eliminating duplicates in<br>d2d_path_geometry_triangulate(). In that case though, it would make<br>more sense to move the vertex count check in that function after the<br>duplicate elimination.<br></div></div><!--<![endif]--></includetail></div>