Menu

#429 d2d1.h HwndRenderTarget GetSize crash incorrect interface

v1.0 (example)
open
nobody
d2d1.h (1)
5
2015-02-27
2014-10-25
Jonathon
No

compiling a simple application that utilizes direct 2d will crash with any call to ID2D1HwndRenderTarget::GetSize() , this is using the latest release build of mingw-w64, win32 threading, and seh exception handling. This bug has been present for a few iterations of mingw-w64. I am using the C++ interface ( D2D_USE_C_DEFINITIONS is not defined ). Looking through the mailing list it seems that the C definitions was fixed for a vlc compilation, although I have not tried to verify this. Attached is as short of an example that will crash that can be written. Link with d2d1 and compile with -std=c++11 (for nullptr use), and it will segfault in the d2d1.h header on ID2D1HwndRenderTarget::GetSize(), if you print m_factory and m_target both are not null, and have been created properly. Please fix this issue.

1 Attachments

Related

Bugs: #429

Discussion

  • Nikolay Sivov

    Nikolay Sivov - 2014-11-08

    This sounds similar to a problem we had in Wine - you can't call d2d methods like GetSize() from C code, because it will need implicit parameter after 'this' pointer. Could you post a full command line/makefile you use to build your test?

     
    • Jonathon

      Jonathon - 2014-11-08

      g++ d2dcrash.cpp -DWINVER=0x0601 -s -static -mwindows -municode -lole32
      -ld2d1 -O3 -o test.exe
      Compile the included example of the issue and it will crash, comment out
      the line that calls the getsize function on the Id2d1HwndRenderTarget
      interface ( should be named m_target ) on line 20 , recompile, execute ,
      and it will not crash, inspection without stripping debug information out
      via gdb shows a segmentation fault occours because the interface is
      incorrect. Searching through Google revealed the previous post about the C
      interface, I've no idea if this has been corrected, however the c++
      interface suffers from the same issue, possiably not because of the same
      reason as previously posted about the C interface. My toolchain : mingw-64
      gcc 4.9.2 seh win32 threads. Windows 7 / 8.1 the example crashes on both
      os's.
      On Nov 8, 2014 11:33 AM, "Nikolay Sivov" nsivov@users.sf.net wrote:

      This sounds similar to a problem we had in Wine - you can't call d2d
      methods like GetSize() from C code, because it will need implicit parameter
      after 'this' pointer. Could you post a full command line/makefile you use
      to build your test?


      Status: open
      Group: v1.0 (example)
      Labels: d2d1.h
      Created: Sat Oct 25, 2014 02:33 PM UTC by Jonathon
      Last Updated: Sat Oct 25, 2014 02:33 PM UTC
      Owner: nobody

      compiling a simple application that utilizes direct 2d will crash with any
      call to ID2D1HwndRenderTarget::GetSize() , this is using the latest release
      build of mingw-w64, win32 threading, and seh exception handling. This bug
      has been present for a few iterations of mingw-w64. I am using the C++
      interface ( D2D_USE_C_DEFINITIONS is not defined ). Looking through the
      mailing list it seems that the C definitions was fixed for a vlc
      compilation, although I have not tried to verify this. Attached is as short
      of an example that will crash that can be written. Link with d2d1 and
      compile with -std=c++11 (for nullptr use), and it will segfault in the
      d2d1.h header on ID2D1HwndRenderTarget::GetSize(), if you print m_factory
      and m_target both are not null, and have been created properly. Please fix
      this issue.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/mingw-w64/bugs/429/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #429

      • Jonathon

        Jonathon - 2014-11-08

        This is what I get after updating to mingw64 gcc 4.9.2 seh win32 threads
        (64 bit toolchain)
        donwloaded from:
        http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z/download

        Usr@Machine ~/Desktop
        $ g++ -std=c++11 d2d1Crash.cpp -g -static -mwindows -municode -lole32
        -ld2d1 -o
        test.exe

        Usr@Machine ~/Desktop
        $ gdb test.exe
        Starting program: c:\Users\Usr\Desktop\test.exe

        [New Thread 1700.0x2f4]
        warning: SHIMVIEW: ShimInfo(Complete)
        GNU gdb (GDB) 7.8.1
        Copyright (C) 2014 Free Software Foundation, Inc.
        License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html

        This is free software: you are free to change and redistribute it.
        There is NO WARRANTY, to the extent permitted by law. Type "show copying"
        and "show warranty" for details.
        This GDB was configured as "x86_64-w64-mingw32".
        Type "show configuration" for configuration details.
        For bug reporting instructions, please see:
        http://www.gnu.org/software/gdb/bugs/.
        Find the GDB manual and other documentation resources online at:
        http://www.gnu.org/software/gdb/documentation/.
        For help, type "help".
        Type "apropos word" to search for commands related to "word"...
        Reading symbols from test.exe...done.
        (gdb) break 20
        Breakpoint 1 at 0x401709: file d2d1Crash.cpp, line 20.
        (gdb) start
        Function "main" not defined.
        Make breakpoint pending on future shared library load? (y or [n]) n
        Breakpoint 1, Render () at d2d1Crash.cpp:20
        20 auto sz = m_target->GetSize();
        (gdb) n
        21 m_target->EndDraw();
        (gdb) n

        Program received signal SIGSEGV, Segmentation fault.
        0x000000000040173c in Render () at d2d1Crash.cpp:21
        21 m_target->EndDraw();
        (gdb) n
        gdb: unknown target exception 0xc000041d at 0x40173c

        Program received signal ?, Unknown signal.
        0x000000000040173c in Render () at d2d1Crash.cpp:21
        21 m_target->EndDraw();
        (gdb) n
        [Inferior 1 (process 1700) exited with code 030000002035]
        (gdb)

        Commenting out line #20 in the provided example and recompiling, and re
        debugging yields:

        Usr@Machine ~/Desktop
        $ g++ -std=c++11 d2d1Crash.cpp -g -static -mwindows -municode -lole32
        -ld2d1 -o
        test.exe

        Usr@Machine ~/Desktop
        $ gdb test.exe
        GNU gdb (GDB) 7.8.1
        Copyright (C) 2014 Free Software Foundation, Inc.
        License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html

        This is free software: you are free to change and redistribute it.
        There is NO WARRANTY, to the extent permitted by law. Type "show copying"
        and "show warranty" for details.
        This GDB was configured as "x86_64-w64-mingw32".
        Type "show configuration" for configuration details.
        For bug reporting instructions, please see:
        http://www.gnu.org/software/gdb/bugs/.
        Find the GDB manual and other documentation resources online at:
        http://www.gnu.org/software/gdb/documentation/.
        For help, type "help".
        Type "apropos word" to search for commands related to "word"...
        Reading symbols from test.exe...done.
        (gdb) break 21
        Breakpoint 1 at 0x401709: file d2d1Crash.cpp, line 21.
        (gdb) start
        Function "main" not defined.
        Make breakpoint pending on future shared library load? (y or [n]) n

        Starting program: c:\Users\Usr\Desktop\test.exe
        [New Thread 7996.0x1a00]
        warning: SHIMVIEW: ShimInfo(Complete)

        Breakpoint 1, Render () at d2d1Crash.cpp:21
        21 m_target->EndDraw();
        (gdb) n
        22 }
        (gdb) //no crash.

        On Sat, Nov 8, 2014 at 2:30 PM, KD kd.boss@gmail.com wrote:

        g++ d2dcrash.cpp -DWINVER=0x0601 -s -static -mwindows -municode -lole32
        -ld2d1 -O3 -o test.exe
        Compile the included example of the issue and it will crash, comment out
        the line that calls the getsize function on the Id2d1HwndRenderTarget
        interface ( should be named m_target ) on line 20 , recompile, execute ,
        and it will not crash, inspection without stripping debug information out
        via gdb shows a segmentation fault occours because the interface is
        incorrect. Searching through Google revealed the previous post about the C
        interface, I've no idea if this has been corrected, however the c++
        interface suffers from the same issue, possiably not because of the same
        reason as previously posted about the C interface. My toolchain : mingw-64
        gcc 4.9.2 seh win32 threads. Windows 7 / 8.1 the example crashes on both
        os's.
        On Nov 8, 2014 11:33 AM, "Nikolay Sivov" nsivov@users.sf.net wrote:

        This sounds similar to a problem we had in Wine - you can't call d2d
        methods like GetSize() from C code, because it will need implicit parameter
        after 'this' pointer. Could you post a full command line/makefile you use
        to build your test?


        Status: open
        Group: v1.0 (example)
        Labels: d2d1.h
        Created: Sat Oct 25, 2014 02:33 PM UTC by Jonathon
        Last Updated: Sat Oct 25, 2014 02:33 PM UTC
        Owner: nobody

        compiling a simple application that utilizes direct 2d will crash with
        any call to ID2D1HwndRenderTarget::GetSize() , this is using the latest
        release build of mingw-w64, win32 threading, and seh exception handling.
        This bug has been present for a few iterations of mingw-w64. I am using the
        C++ interface ( D2D_USE_C_DEFINITIONS is not defined ). Looking through the
        mailing list it seems that the C definitions was fixed for a vlc
        compilation, although I have not tried to verify this. Attached is as short
        of an example that will crash that can be written. Link with d2d1 and
        compile with -std=c++11 (for nullptr use), and it will segfault in the
        d2d1.h header on ID2D1HwndRenderTarget::GetSize(), if you print m_factory
        and m_target both are not null, and have been created properly. Please fix
        this issue.


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/mingw-w64/bugs/429/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

        --
        ¯°²º¤æ=.KD.=椺²°¯

         

        Related

        Bugs: #429


        Last edit: Jonathon 2014-11-08
    • Jonathon

      Jonathon - 2015-02-27

      debug build is follows.

      g++ d2dcrash.cpp -DWINVER=0x0601 -g -static -mwindows -municode -lole32 -ld2d1 -o d2dcrash.exe

      this of course expects a shell that has the tool chain installed. I'm not highly familiar with creating makefiles, I typically use cmake or Qt's build system, but if you absolutely require a makefile I could try to cobble one together for you.

      This bug has been persistent across a few revisions of mingw-64, and I'm not the first to report it, though I've followed all the suggestions on the other post trying to track it down myself. The interface as far as the ORDER of the function definitions is concerned is correct, as far as I can tell, compared against the windows sdk 7.1

      If you compile and run any of the code on microsoft's "Teach yourself C++" site that uses d2d1 it will do the same thing, as they all use the GetSize() function in their Render() method.

      a good example of this would be the following.
      https://msdn.microsoft.com/en-us/library/windows/desktop/ff684181%28v=vs.85%29.aspx

       
  • Jonathon

    Jonathon - 2015-02-27
     

Log in to post a comment.