Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: libgo/mksigtab.sh broken on ppc64le with upstream glibc change affecting _NSIG #21147

Closed
laboger opened this issue Jul 24, 2017 · 5 comments
Milestone

Comments

@laboger
Copy link
Contributor

laboger commented Jul 24, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

gccgo from gcc 7

What operating system and processor architecture are you using (go env)?

Ubuntu 16.04 ppc64le

What did you do?

We have a build team attempting to build gccgo from the gcc-7 branch using upstream glibc which will be 2.26.

What did you expect to see?

Successful build.

What did you see instead?

Runtime errors when using the built gccgo. This happens when attempting to do:
go version

panic: runtime error: index out of range

Through debugging it was found that the problem occurs in
libgo/go/runtime/signal_unix.go:85
Inside function initseg is this loop:

 for i := uint32(0); i < _NSIG; i++ {
                t := &sigtable[i]        <----- error occurs here because len(sigtable) and _NSIG don't match
                if t.flags == 0 || t.flags&_SigDefault != 0 {
                        continue
                } 
                fwdSig[i] = getsig(i)

                if !sigInstallGoHandler(i) {
                        // Even if we are not installing a signal handler,
                        // set SA_ONSTACK if necessary.
                        if fwdSig[i] != _SIG_DFL && fwdSig[i] != _SIG_IGN {
                                setsigstack(i)
                        }
                        continue
                }

                t.flags |= _SigHandling
                setsig(i, getSigtramp())
        }

Further debugging shows that the sigtab.go file is generated incorrectly. The value of _NSIG ends up being 65 but there are only 34 entries put into the sigtable.

The reason for this is this line in mksigtab.sh:

nsig=grep 'const _*NSIG = [0-9]*$' gen-sysinfo.go | sed -e 's/.* = \([0-9]*\)/\1/'

But _NSIG in gen-sysinfo.go now looks like this so doesn't match:

const __NSIG = (___SIGRTMAX + 1)

The glibc patch that causes the issue is https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=8082d91e1c449e0cb137468b731004a5e605c8c6.

@ianlancetaylor If you have a workaround to suggest, that would be appreciated.

@gopherbot gopherbot added this to the Gccgo milestone Jul 24, 2017
@laboger laboger changed the title gccgo: libgo/mksigtab.sh broken with upstream glibc change affecting _NSIG gccgo: libgo/mksigtab.sh broken on ppc64le with upstream glibc change affecting _NSIG Jul 24, 2017
tuliom added a commit to tuliom/advance-toolchain that referenced this issue Jul 28, 2017
Work around issue golang/go#21147.

This is mandatory for a glibc 2.26 update.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
tuliom added a commit to advancetoolchain/advance-toolchain that referenced this issue Aug 1, 2017
Work around issue golang/go#21147.

This is mandatory for a glibc 2.26 update.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
@ianlancetaylor
Copy link
Contributor

What is the definition of ___SIGRTMAX in the generated file gen-sysinfo.go?

@gopherbot
Copy link

Change https://golang.org/cl/52611 mentions this issue: libgo: change mksigtab to recognize glibc 2.26 NSIG expression

@ianlancetaylor
Copy link
Contributor

@laboger Could you see if https://golang.org/cl/52611 fixes the problem? Thanks.

tuliom pushed a commit to tuliom/gcc that referenced this issue Aug 2, 2017
tuliom pushed a commit to tuliom/gcc that referenced this issue Aug 3, 2017
Fixes golang/go#21147
Fixes GCC PR 81617libgo: Workaround for new signal.h on glibc 2.26
@tuliom
Copy link

tuliom commented Aug 3, 2017

@ianlancetaylor, that patch needs a fix. Line 111 needs to redirect the output of grep to /dev/null.

After that fix, the patch works. Tested on GCC 7.0 with this patch: tuliom/gcc@ba1df33

@ianlancetaylor
Copy link
Contributor

@tuliom Thanks, I updated the CL.

hubot pushed a commit to gcc-mirror/gcc that referenced this issue Aug 3, 2017
    libgo: change mksigtab to recognize glibc 2.26 NSIG expression
    
    Fixes golang/go#21147
    Fixes GCC PR 81617
    
    Reviewed-on: https://go-review.googlesource.com/52611


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250858 138bc75d-0d04-0410-961f-82ee72b054a4
hubot pushed a commit to gcc-mirror/gcc that referenced this issue Aug 4, 2017
    libgo: change mksigtab to recognize glibc 2.26 NSIG expression
    
    Fixes golang/go#21147
    Fixes GCC PR 81617
    
    Reviewed-on: https://go-review.googlesource.com/52611


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@250872 138bc75d-0d04-0410-961f-82ee72b054a4
@golang golang locked and limited conversation to collaborators Aug 3, 2018
asiekierka pushed a commit to WonderfulToolchain/gcc-ia16 that referenced this issue May 16, 2022
	PR go/81617
    libgo: change mksigtab to recognize glibc 2.26 NSIG expression
    
    Fixes golang/go#21147
    Fixes GCC PR 81617
    
    Reviewed-on: https://go-review.googlesource.com/52611

From-SVN: r250858
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants