Git Product home page Git Product logo

libgore's Issues

Library hangs on macOS

Looks like a bug in CGO

#include <stdio.h>
#include "libgore.h"

int main()
{
   int v;
   char* fp = "/path/to/pygore/test/resources/golden";
   printf("Open %s\n", fp);
   v = open(fp);
   printf("Return code %d\n", v);
   return 0;
}

Compile on macOS with: gcc -o test test.c libgore.dylib

Function calls go_wait_runtime_init_done:

libgore.dylib`open:
    0x1001ced80 <+0>:  pushq  %rbp
    0x1001ced81 <+1>:  movq   %rsp, %rbp
    0x1001ced84 <+4>:  pushq  %r14
    0x1001ced86 <+6>:  pushq  %rbx
    0x1001ced87 <+7>:  subq   $0x10, %rsp
    0x1001ced8b <+11>: movq   %rdi, %r14
    0x1001ced8e <+14>: xorl   %eax, %eax
->  0x1001ced90 <+16>: callq  0x1001cf420               ; _cgo_wait_runtime_init_done
    0x1001ced95 <+21>: movq   %rax, %rbx
    0x1001ced98 <+24>: movq   %r14, -0x20(%rbp)
    0x1001ced9c <+28>: leaq   -0x4813(%rip), %rdi       ; _cgoexp_c54285109ac3_goopen
    0x1001ceda3 <+35>: leaq   -0x20(%rbp), %rsi
    0x1001ceda7 <+39>: movl   $0x10, %edx
    0x1001cedac <+44>: movq   %rax, %rcx
    0x1001cedaf <+47>: callq  0x1001c9c80               ; crosscall2
    0x1001cedb4 <+52>: movq   %rbx, %rdi
    0x1001cedb7 <+55>: callq  0x1001cf0f0               ; _cgo_release_context
    0x1001cedbc <+60>: movl   -0x18(%rbp), %eax
    0x1001cedbf <+63>: addq   $0x10, %rsp
    0x1001cedc3 <+67>: popq   %rbx
    0x1001cedc4 <+68>: popq   %r14
    0x1001cedc6 <+70>: popq   %rbp
    0x1001cedc7 <+71>: retq   
    0x1001cedc8 <+72>: nopl   (%rax,%rax)

That hangs on pthread_cond_wait

libgore.dylib`_cgo_wait_runtime_init_done:
    0x1001cf420 <+0>:   pushq  %rbp
    0x1001cf421 <+1>:   movq   %rsp, %rbp
    0x1001cf424 <+4>:   pushq  %r14
    0x1001cf426 <+6>:   pushq  %rbx
    0x1001cf427 <+7>:   subq   $0x10, %rsp
    0x1001cf42b <+11>:  leaq   0x15123e(%rip), %rdi      ; runtime_init_mu
    0x1001cf432 <+18>:  callq  0x1001cf74a               ; symbol stub for: pthread_mutex_lock
    0x1001cf437 <+23>:  cmpb   $0x0, 0x16d5b2(%rip)      ; runtime.trace + 65743
    0x1001cf43e <+30>:  jne    0x1001cf464               ; <+68>
    0x1001cf440 <+32>:  leaq   0x151269(%rip), %r14      ; runtime_init_cond
    0x1001cf447 <+39>:  leaq   0x151222(%rip), %rbx      ; runtime_init_mu
    0x1001cf44e <+46>:  nop    
    0x1001cf450 <+48>:  movq   %r14, %rdi
    0x1001cf453 <+51>:  movq   %rbx, %rsi
->  0x1001cf456 <+54>:  callq  0x1001cf732               ; symbol stub for: pthread_cond_wait
    0x1001cf45b <+59>:  cmpb   $0x1, 0x16d58e(%rip)      ; runtime.trace + 65743
    0x1001cf462 <+66>:  jne    0x1001cf450               ; <+48>
    0x1001cf464 <+68>:  movq   0x16d58d(%rip), %rbx      ; cgo_context_function
    0x1001cf46b <+75>:  leaq   0x1511fe(%rip), %rdi      ; runtime_init_mu
    0x1001cf472 <+82>:  callq  0x1001cf750               ; symbol stub for: pthread_mutex_unlock
    0x1001cf477 <+87>:  testq  %rbx, %rbx
    0x1001cf47a <+90>:  je     0x1001cf490               ; <+112>
    0x1001cf47c <+92>:  movq   $0x0, -0x18(%rbp)
    0x1001cf484 <+100>: leaq   -0x18(%rbp), %rdi
    0x1001cf488 <+104>: callq  *%rbx
    0x1001cf48a <+106>: movq   -0x18(%rbp), %rax
    0x1001cf48e <+110>: jmp    0x1001cf492               ; <+114>
    0x1001cf490 <+112>: xorl   %eax, %eax
    0x1001cf492 <+114>: addq   $0x10, %rsp
    0x1001cf496 <+118>: popq   %rbx
    0x1001cf497 <+119>: popq   %r14
    0x1001cf499 <+121>: popq   %rbp
    0x1001cf49a <+122>: retq   
    0x1001cf49b <+123>: nopl   (%rax,%rax)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.