FAQ
I've got this on the Rapberry Pi, could someone test it
on another ARM box?

I filled a issue https://code.google.com/p/go/issues/detail?id=5227

Thanks.

$cat main.go
package main

//#include "init.h"
import "C"

func main() {
C.init()
}

func selectfont() C.Fontinfo {
return C.SansTypeface
}


$cat init.h
typedef struct {
int Count;
} Fontinfo;

Fontinfo SansTypeface;

extern void init();



$cat init.c
#include "init.h"

Fontinfo loadfont() {
Fontinfo f;
return f;
}

void init() {
SansTypeface = loadfont();
}



fatal error: malloc/free - deadlock
[signal 0xb code=0x1 addr=0x2f0 pc=0x28efc]

goroutine 1 [syscall]:
[fp=0xb694ef80] return()
/data/go/src/pkg/runtime/asm_arm.s:275
[fp=0xb694efa8] runtime.cgocall(0x2e0fc, 0xb694efb8)
/data/go/src/pkg/runtime/cgocall.c:162 +0xec
[fp=0xb694efb4] main._Cfunc_init(0x22a4c)
issue5227/_obj/_cgo_defun.c:47 +0x30
[fp=0xb694efb8] main.main()
issue5227/_obj/_cgo_gotypes.go:38 +0x20
[fp=0xb694efd0] runtime.main()
/data/go/src/pkg/runtime/proc.c:182 +0x78
[fp=0xb694efd4] runtime.goexit()
/data/go/src/pkg/runtime/proc.c:1223

goroutine 2 [syscall]:
runtime.goexit()
/data/go/src/pkg/runtime/proc.c:1223

goroutine 3 [syscall]:
runtime.entersyscallblock()
/data/go/src/pkg/runtime/proc.c:1333 +0xc0
runtime.MHeap_Scavenger()
/data/go/src/pkg/runtime/mheap.c:434 +0xfc
runtime.goexit()
/data/go/src/pkg/runtime/proc.c:1223
created by runtime.main
/data/go/src/pkg/runtime/proc.c:165

--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Minux at Apr 8, 2013 at 10:08 pm
    Reproduced on fedora/arm vm. Thank you for reporting this.
    On Tue, Apr 9, 2013 at 2:55 AM, capnm wrote:
    I've got this on the Rapberry Pi, could someone test it
    on another ARM box?

    I filled a issue https://code.google.com/p/go/issues/detail?id=5227

    Thanks.

    $cat main.go
    package main

    //#include "init.h"
    import "C"

    func main() {
    C.init()
    }

    func selectfont() C.Fontinfo {
    return C.SansTypeface
    }


    $cat init.h
    typedef struct {
    int Count;
    } Fontinfo;

    Fontinfo SansTypeface;

    extern void init();



    $cat init.c
    #include "init.h"

    Fontinfo loadfont() {
    Fontinfo f;
    return f;
    }

    void init() {
    SansTypeface = loadfont();
    }



    fatal error: malloc/free - deadlock
    [signal 0xb code=0x1 addr=0x2f0 pc=0x28efc]

    goroutine 1 [syscall]:
    [fp=0xb694ef80] return()
    /data/go/src/pkg/runtime/asm_arm.s:275
    [fp=0xb694efa8] runtime.cgocall(0x2e0fc, 0xb694efb8)
    /data/go/src/pkg/runtime/cgocall.c:162 +0xec
    [fp=0xb694efb4] main._Cfunc_init(0x22a4c)
    issue5227/_obj/_cgo_defun.c:47 +0x30
    [fp=0xb694efb8] main.main()
    issue5227/_obj/_cgo_gotypes.go:38 +0x20
    [fp=0xb694efd0] runtime.main()
    /data/go/src/pkg/runtime/proc.c:182 +0x78
    [fp=0xb694efd4] runtime.goexit()
    /data/go/src/pkg/runtime/proc.c:1223

    goroutine 2 [syscall]:
    runtime.goexit()
    /data/go/src/pkg/runtime/proc.c:1223

    goroutine 3 [syscall]:
    runtime.entersyscallblock()
    /data/go/src/pkg/runtime/proc.c:1333 +0xc0
    runtime.MHeap_Scavenger()
    /data/go/src/pkg/runtime/mheap.c:434 +0xfc
    runtime.goexit()
    /data/go/src/pkg/runtime/proc.c:1223
    created by runtime.main
    /data/go/src/pkg/runtime/proc.c:165

    --

    ---
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rémy Oudompheng at Apr 8, 2013 at 10:08 pm

    2013/4/8 capnm <capnm9@gmail.com>:
    I've got this on the Rapberry Pi, could someone test it
    on another ARM box?

    I filled a issue https://code.google.com/p/go/issues/detail?id=5227
    I can reproduce. Weirdly enough, SansTypeface is an undefined symbol
    in the resulting binary:

    $ readelf -s testcgo | grep face
    757: 00000000 0 NOTYPE GLOBAL DEFAULT UND SansTypeface

    I am inclined to say that this is a linker bug.

    Rémy.

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Capnm at Apr 8, 2013 at 10:54 pm

    On Tuesday, 9 April 2013 00:08:39 UTC+2, Rémy wrote:
    2013/4/8 capnm <cap...@gmail.com <javascript:>>:
    I've got this on the Rapberry Pi, could someone test it
    on another ARM box?

    I filled a issue https://code.google.com/p/go/issues/detail?id=5227
    I can reproduce. Weirdly enough, SansTypeface is an undefined symbol
    in the resulting binary:

    $ readelf -s testcgo | grep face
    757: 00000000 0 NOTYPE GLOBAL DEFAULT UND SansTypeface

    I am inclined to say that this is a linker bug.

    Rémy.
    You may be right, a bisect found that the bug was introduced in this commit:
    https://code.google.com/p/go/source/detail?name=95c3a7bdfb03&r=97cbf15abc2c18b2616349d1f936cd6e7a584b76

    I guess it did something more than "replace -hostobj with -linkmode".

    Thanks,
    Martin

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Capnm at Apr 9, 2013 at 12:53 am

    I can reproduce. Weirdly enough, SansTypeface is an undefined symbol
    in the resulting binary:

    $ readelf -s testcgo | grep face
    757: 00000000 0 NOTYPE GLOBAL DEFAULT UND SansTypeface

    I am inclined to say that this is a linker bug.

    Rémy.
    You may be right, a bisect found that the bug was introduced in this
    commit:

    https://code.google.com/p/go/source/detail?name=95c3a7bdfb03&r=97cbf15abc2c18b2616349d1f936cd6e7a584b76

    I guess it did something more than "replace -hostobj with -linkmode".

    Luckily, I'm not expected to understand this.
    This was the only functional change and reverting
    it indeed fixes this bug on tip.

    Thanks,
    Martin

    diff --git a/src/cmd/ld/go.c b/src/cmd/ld/go.c
    index fa2ec4e..38084ca 100644
    --- a/src/cmd/ld/go.c
    +++ b/src/cmd/ld/go.c
    @@ -476,10 +476,12 @@ loadcgo(char *file, char *pkg, char *p, int n)
    if(strcmp(f[0], "cgo_import_static") == 0) {
    if(nf != 2)
    goto err;
    - local = f[1];
    - s = lookup(local, 0);
    - s->type = SHOSTOBJ;
    - s->size = 0;
    + if(linkmode == LinkExternal) {
    + local = f[1];
    + s = lookup(local, 0);
    + s->type = SHOSTOBJ;
    + s->size = 0;
    + }
    continue;
    }



    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ian Lance Taylor at Apr 9, 2013 at 6:47 pm

    On Mon, Apr 8, 2013 at 5:53 PM, capnm wrote:
    I can reproduce. Weirdly enough, SansTypeface is an undefined symbol
    in the resulting binary:

    $ readelf -s testcgo | grep face
    757: 00000000 0 NOTYPE GLOBAL DEFAULT UND SansTypeface

    I am inclined to say that this is a linker bug.

    Rémy.

    You may be right, a bisect found that the bug was introduced in this
    commit:

    https://code.google.com/p/go/source/detail?name=95c3a7bdfb03&r=97cbf15abc2c18b2616349d1f936cd6e7a584b76

    I guess it did something more than "replace -hostobj with -linkmode".


    Luckily, I'm not expected to understand this.
    This was the only functional change and reverting
    it indeed fixes this bug on tip.

    Thanks,
    Martin

    diff --git a/src/cmd/ld/go.c b/src/cmd/ld/go.c
    index fa2ec4e..38084ca 100644
    --- a/src/cmd/ld/go.c
    +++ b/src/cmd/ld/go.c
    @@ -476,10 +476,12 @@ loadcgo(char *file, char *pkg, char *p, int n)
    if(strcmp(f[0], "cgo_import_static") == 0) {
    if(nf != 2)
    goto err;
    - local = f[1];
    - s = lookup(local, 0);
    - s->type = SHOSTOBJ;
    - s->size = 0;
    + if(linkmode == LinkExternal) {
    + local = f[1];
    + s = lookup(local, 0);
    + s->type = SHOSTOBJ;
    + s->size = 0;
    + }
    continue;
    }
    Rémy's patch in issue 5227, suitably modified to check linkmode, is
    better. The problem with the patch above is that linkmode may change
    after all the input files are read.

    Ian

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedApr 8, '13 at 9:48p
activeApr 9, '13 at 6:47p
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase