{"id":5382,"date":"2014-03-30T21:17:35","date_gmt":"2014-03-30T21:17:35","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/segfault-at-creation-class-after-cross-compilation-for-windows-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:17:35","modified_gmt":"2014-03-30T21:17:35","slug":"segfault-at-creation-class-after-cross-compilation-for-windows-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/segfault-at-creation-class-after-cross-compilation-for-windows-collection-of-common-programming-errors\/","title":{"rendered":"segfault at creation-class after cross-compilation for Windows-Collection of common programming errors"},"content":{"rendered":"<p>I try to create a prorgam using SFML 2.0 for Windows, using a Gentoo Linux with mingw32.<\/p>\n<p>I don&#8217;t want to recompile SFML and all it&#8217;s dependencies, so i&#8217;ve downloaded a compiled version from the official site (version 32 bits &#8211; SJLJ)<\/p>\n<p>I have compiled my code, and executed it on wine, but it segfault when i try to instanciate a class from SFML. I have tried using static or dynamic version of SFML, nothing change.<\/p>\n<p>Using debug mode, it seem that the <code>this<\/code> value is not correctly initialized on SFML classes.<\/p>\n<p><em>my compilation flags:<\/em><\/p>\n<pre><code>CXXFLAGS = -W -Wall -ggdb3 -ISFML-2.0-rc\/include -DSFML_STATIC\nLDFLAGS  = -LSFML-2.0-rc\/lib -static-libgcc -static-libstdc++ -mwindows      \\\n           -lsfml-window-s-d -lsfml-graphics-s-d -lsfml-system-s-d -lws2_32\n<\/code><\/pre>\n<p><em>main.cpp:<\/em><\/p>\n<pre><code>#include \n\nint main() {\n  sf::VideoMode vm(800, 600);\n\n  return 0;\n}\n<\/code><\/pre>\n<p><em>wine error:<\/em><\/p>\n<pre><code>wine: Unhandled page fault on write access to 0x00000320 at address 0x4021e9 (thread 0026), starting debugger...\nUnhandled exception: page fault on write access to 0x00000320 in 32-bit code (0x004021e9).\nRegister dump:\n CS:0023 SS:002b DS:002b ES:002b FS:0063 GS:006b\n EIP:004021e9 ESP:0087fd78 EBP:0087fd78 EFLAGS:00010202(  R- --  I   - - - )\n EAX:00000320 EBX:7b896ff4 ECX:0087fdd4 EDX:00000258\n ESI:7ffdf000 EDI:004012b0\nStack dump:\n0x0087fd78:  0087fdf8 004013bd 00000320 00000258\n0x0087fd88:  00000020 0040c387 00401340 004012b0\n0x0087fd98:  0087fdc8 00000000 00000001 7ffdf000\n0x0087fda8:  0087fdc8 7ed71ff4 00409fc0 00418d28\n0x0087fdb8:  00419370 0087fde0 004013ca 0087fd80\n0x0087fdc8:  0087fde8 0040b162 00000001 0000ffff\nBacktrace:\n=&gt;0 0x004021e9 VideoMode+0x9(this=0x320, modeWidth=0x258, modeHeight=0x20, modeBitsPerPixel=0x40c387) [D:\\developpement\\sfml-misc\\release\\2.0-rc1\\gcc4-sjlj\\debug-static\\src\\SFML\\Window\/D:\/developpement\/sfml-master\/src\/SFML\/Window\/VideoMode.cpp:50] in chess (0x0087fd78)\n  1 0x004013bd main+0x6c() [\/home\/bak\/projets\/bjtu\/server architecture\/Chess\/main.cpp:5] in chess (0x0087fdf8)\n  2 0x004010fd in chess (+0x10fc) (0x0087fe88)\n  3 0x7b85d80f in kernel32 (+0x4d80e) (0x0087fec8)\n  4 0x7bc73ed0 call_thread_func_wrapper+0xb() in ntdll (0x0087fed8)\n  5 0x7bc7690d call_thread_func+0x7c() in ntdll (0x0087ffa8)\n  6 0x7bc73eae RtlRaiseException+0x21() in ntdll (0x0087ffc8)\n  7 0x7bc4c78e call_dll_entry_point+0x61d() in ntdll (0x0087ffe8)\n  8 0xf767106d wine_call_on_stack+0x1c() in libwine.so.1 (0x00000000)\n  9 0xf767112b wine_switch_to_stack+0x2a() in libwine.so.1 (0xffd55c28)\n  10 0x7bc51e6f LdrInitializeThunk+0x2ee() in ntdll (0xffd55c98)\n  11 0x7b86371a __wine_kernel_init+0xa19() in kernel32 (0xffd56e38)\n  12 0x7bc5269b __wine_process_init+0x25a() in ntdll (0xffd56eb8)\n  13 0xf766e5e2 wine_init+0x291() in libwine.so.1 (0xffd56f28)\n  14 0x7bf0106b main+0x7a() in  (0xffd57378)\n  15 0xf74b6596 __libc_start_main+0xe5() in libc.so.6 (0xffd573f8)\n0x004021e9 VideoMode+0x9 [D:\\developpement\\sfml-misc\\release\\2.0-rc1\\gcc4-sjlj\\debug-static\\src\\SFML\\Window\/D:\/developpement\/sfml-master\/src\/SFML\/Window\/VideoMode.cpp:50] in chess: movl   %edx,0x0(%eax)\n<\/code><\/pre>\n<p><code>VideoMode.cpp:50<\/code> refer to the end of contructor, like with others SFML classes i&#8217;ve tried to use.<\/p>\n<p>The <code>this<\/code> variable is not correctly initialised:<\/p>\n<pre><code> =&gt;0 0x004021e9 VideoMode+0x9(this=0x320, modeWidth=0x258, ...\n<\/code><\/pre>\n<p><code>this<\/code> take the value of the first param, and all others values are shifted (fisrt arg has the second value, &#8230;)<\/p>\n<p>I&#8217;ve tested with severals classes with the same result.<\/p>\n<p>From wich may be the problem ?<br \/>\nI&#8217;ve thought a difference between calling conventions, but i&#8217;m not sure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I try to create a prorgam using SFML 2.0 for Windows, using a Gentoo Linux with mingw32. I don&#8217;t want to recompile SFML and all it&#8217;s dependencies, so i&#8217;ve downloaded a compiled version from the official site (version 32 bits &#8211; SJLJ) I have compiled my code, and executed it on wine, but it segfault [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5382","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5382"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5382\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}