<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - glx: make check fails to build on osx"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=91106">91106</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>glx: make check fails to build on osx
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Mac OS X (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Mesa core
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>julien.isorce@gmail.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=116709" name="attach_116709" title="glx: fix unit tests build on osx">attachment 116709</a> <a href="attachment.cgi?id=116709&action=edit" title="glx: fix unit tests build on osx">[details]</a></span>
glx: fix unit tests build on osx

It fails because of missing symbols and some duplicated symbols.

The attached patch adds missing dependencies in tests/Makefile.am to fix some
missing symbols.

The attached patch also marks some functions with attribute weak to fix some
duplicated symbols due to redefinitions in the unit tests.

It allows to fix the build.

Then it passes some tests but crash around the 30th test
(glXCreateContextAttribARB_test.does_send_protocol):

It seems to crash when calling apple_cgl.choose_pixel_format. I investigated a
bit and glx/apple/apple_cgl.c::apple_cgl_init is not called (so
apple_cgl.choose_pixel_format = sym(h, "CGLChoosePixelFormat"); is not called).

backtrace with lldb:

* thread #1: tid = 0x86cd39, 0x0000000000000000, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
(lldb) bt
* thread #1: tid = 0x86cd39, 0x0000000000000000, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x00000001000879fa
glx-test`apple_visual_create_pfobj(pfobj=0x0000000100c22e88,
mode=0x0000000100c22328, double_buffered=0x0000000100c22ea4,
uses_stereo=0x0000000100c22ea5, offscreen=false) + 1610 at apple_visual.c:169
    frame #2: 0x00000001000833b9
glx-test`apple_glx_create_context(ptr=0x0000000100c22de8,
dpy=0x0000000000000000, screen=0, mode=0x0000000100c22328,
sharedContext=0x0000000000000000, errorptr=0x00007fff5fbff09c,
x11errorptr=0x00007fff5fbff09b) + 377 at apple_glx_context.c:161
    frame #3: 0x00000001000823ec
glx-test`applegl_create_context(psc=0x0000000100c22c90,
config=0x0000000100c22328, shareList=0x0000000000000000, renderType=0) + 332 at
applegl_glx.c:150
    frame #4: 0x00000001000439f3
glx-test`glXCreateContextAttribsARB(dpy=0x000000010100e400,
config=0x0000000100c22328, share_context=0x0000000000000000, direct=0,
attrib_list=0x0000000000000000) + 451 at create_context.c:86
    frame #5: 0x00000001000155c1
glx-test`glXCreateContextAttribARB_test_does_send_protocol_Test::TestBody(this=0x0000000100c22310)
+ 97 at create_context_unittest.cpp:221
    frame #6: 0x00000001004a1f13 glx-test`void
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
void>(object=0x0000000100c22310, method=0x0000000000000021,
location=0x000000010057f3fd)(), char const*) + 131 at gtest.cc:2078
    frame #7: 0x000000010048c7b7 glx-test`void
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,
void>(object=0x0000000100c22310, method=0x0000000000000021,
location=0x000000010057f3fd)(), char const*) + 119 at gtest.cc:2114
    frame #8: 0x0000000100465b05
glx-test`testing::Test::Run(this=0x0000000100c22310) + 197 at gtest.cc:2150
    frame #9: 0x0000000100466ddb
glx-test`testing::TestInfo::Run(this=0x0000000100c1a420) + 219 at gtest.cc:2326
    frame #10: 0x0000000100467d07
glx-test`testing::TestCase::Run(this=0x0000000100c1a040) + 231 at gtest.cc:2444
    frame #11: 0x00000001004747f8
glx-test`testing::internal::UnitTestImpl::RunAllTests(this=0x0000000100c17590)
+ 952 at gtest.cc:4315
    frame #12: 0x000000010049ed93 glx-test`bool
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
bool>(object=0x0000000100c17590, method=0x0000000100474440,
location=0x000000010057fabc)(), char const*) + 131 at gtest.cc:2078
    frame #13: 0x000000010048efc7 glx-test`bool
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
bool>(object=0x0000000100c17590, method=0x0000000100474440,
location=0x000000010057fabc)(), char const*) + 119 at gtest.cc:2114
    frame #14: 0x00000001004743b6
glx-test`testing::UnitTest::Run(this=0x00000001005b3458) + 422 at gtest.cc:3926
    frame #15: 0x00000001004ac491 glx-test`RUN_ALL_TESTS() + 17 at gtest.h:2288
    frame #16: 0x00000001004ac46c glx-test`main(argc=1,
argv=0x00007fff5fbffac0) + 60 at gtest_main.cc:37
    frame #17: 0x00007fff886ee5c9 libdyld.dylib`start + 1

Also I tried to manually call __glXInitialize (because it is never called) in
tests/create_context_unittest.cpp::GetGLXScreenConfigs existing redefinition:

 GetGLXScreenConfigs(Display * dpy, int scrn)
 {
+   if(psc)
+     __glXInitialize(dpy);

But it still does not make "apple_cgl_init" to be called, because it crashes in
glxext.c:847:   dpyPriv->codes = XInitExtension(dpy, __glXExtensionName);

* thread #1: tid = 0x86de8e, 0x0000000100989057 libX11.6.dylib`require_socket +
32, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
address=0x40)
    frame #0: 0x0000000100989057 libX11.6.dylib`require_socket + 32
libX11.6.dylib`require_socket + 32:
-> 0x100989057:  cmpl   $0x0, 0x40(%rax)
   0x10098905b:  setne  %cl
   0x10098905e:  movzbl %cl, %ecx
   0x100989061:  movq   (%rax), %rdi
(lldb) bt
* thread #1: tid = 0x86de8e, 0x0000000100989057 libX11.6.dylib`require_socket +
32, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
address=0x40)
  * frame #0: 0x0000000100989057 libX11.6.dylib`require_socket + 32
    frame #1: 0x0000000100989018 libX11.6.dylib`_XFlush + 14
    frame #2: 0x000000010098a1fb libX11.6.dylib`_XGetRequest + 53
    frame #3: 0x000000010098036f libX11.6.dylib`XQueryExtension + 68
    frame #4: 0x0000000100975a80 libX11.6.dylib`XInitExtension + 36
    frame #5: 0x0000000100048fc4
glx-test`__glXInitialize(dpy=0x0000000101803c00) + 308 at glxext.c:847
    frame #6: 0x000000010001490b
glx-test`GetGLXScreenConfigs(dpy=0x0000000101803c00, scrn=0) + 75 at
create_context_unittest.cpp:70
    frame #7: 0x00000001000438bd
glx-test`glXCreateContextAttribsARB(dpy=0x0000000101803c00,
config=0x0000000100d00098, share_context=0x0000000000000000, direct=0,
attrib_list=0x0000000000000000) + 141 at create_context.c:59
    frame #8: 0x00000001000155c1
glx-test`glXCreateContextAttribARB_test_does_send_protocol_Test::TestBody(this=0x0000000100d00080)
+ 97 at create_context_unittest.cpp:221
    frame #9: 0x00000001004a1f13 glx-test`void
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,
void>(object=0x0000000100d00080, method=0x0000000000000021,
location=0x000000010057f3fd)(), char const*) + 131 at gtest.cc:2078
    frame #10: 0x000000010048c7b7 glx-test`void
testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,
void>(object=0x0000000100d00080, method=0x0000000000000021,
location=0x000000010057f3fd)(), char const*) + 119 at gtest.cc:2114
    frame #11: 0x0000000100465b05
glx-test`testing::Test::Run(this=0x0000000100d00080) + 197 at gtest.cc:2150
    frame #12: 0x0000000100466ddb
glx-test`testing::TestInfo::Run(this=0x0000000100c1a420) + 219 at gtest.cc:2326
    frame #13: 0x0000000100467d07
glx-test`testing::TestCase::Run(this=0x0000000100c1a040) + 231 at gtest.cc:2444
    frame #14: 0x00000001004747f8
glx-test`testing::internal::UnitTestImpl::RunAllTests(this=0x0000000100c17590)
+ 952 at gtest.cc:4315
    frame #15: 0x000000010049ed93 glx-test`bool
testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
bool>(object=0x0000000100c17590, method=0x0000000100474440,
location=0x000000010057fabc)(), char const*) + 131 at gtest.cc:2078
    frame #16: 0x000000010048efc7 glx-test`bool
testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,
bool>(object=0x0000000100c17590, method=0x0000000100474440,
location=0x000000010057fabc)(), char const*) + 119 at gtest.cc:2114
    frame #17: 0x00000001004743b6
glx-test`testing::UnitTest::Run(this=0x00000001005b3458) + 422 at gtest.cc:3926
    frame #18: 0x00000001004ac491 glx-test`RUN_ALL_TESTS() + 17 at gtest.h:2288
    frame #19: 0x00000001004ac46c glx-test`main(argc=1,
argv=0x00007fff5fbffac0) + 60 at gtest_main.cc:37
    frame #20: 0x00007fff886ee5c9 libdyld.dylib`start + 1
(lldb) 

Any comment about the patch to fix the build and about the crashes ?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>