public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug go/56171] New: syscall FAILs on Solaris
@ 2013-02-01 12:05 ro at gcc dot gnu.org
  2013-02-02 15:40 ` [Bug go/56171] " ian at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: ro at gcc dot gnu.org @ 2013-02-01 12:05 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

             Bug #: 56171
           Summary: syscall FAILs on Solaris
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: go
        AssignedTo: ian@airs.com
        ReportedBy: ro@gcc.gnu.org
              Host: *-*-solaris2.*
            Target: *-*-solaris2.*
             Build: *-*-solaris2.*


The libgo syscall tests currently FAILs on Solaris:

creds_test.go:22:41: error: reference to undefined identifier
'syscall.AF_LOCAL'
  fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM, 0)
                                         ^
creds_test.go:29:66: error: reference to undefined identifier
'syscall.SO_PASSCR
ED'
  err = syscall.SetsockoptInt(fds[0], syscall.SOL_SOCKET, syscall.SO_PASSCRED,
1
)
                                                                  ^
creds_test.go:52:12: error: reference to undefined identifier 'syscall.Ucred'
  var ucred syscall.Ucred
            ^
creds_test.go:57:18: error: reference to undefined identifier
'syscall.UnixCrede
ntials'
   oob := syscall.UnixCredentials(&ucred)
                  ^
creds_test.go:67:17: error: reference to undefined identifier
'syscall.UnixCrede
ntials'
  oob := syscall.UnixCredentials(&ucred)
                 ^
creds_test.go:106:27: error: reference to undefined identifier
'syscall.ParseUnixCredentials'
  newUcred, err := syscall.ParseUnixCredentials(&scm[0])
                           ^
passfd_test.go:40:41: error: reference to undefined identifier
'syscall.AF_LOCAL
'
  fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM, 0)
                                         ^
FAIL: syscall

There are two issues here:

* passfd_test.go uses AF_LOCAL, which only exists from Solaris 11 onwards and
  is an alternative name for the more common AF_UNIX.  One could either provide
  AF_LOCAL in mksysinfo.sh if missing or directly use AF_UNIX, as is already
  done in go/net/file_unix.go, go/net/unixsock_posix.go, go/syscall/socket.go.

* creds_test.go uses Ucred, UnixCredentials, and SO_PASSCRED, which in their
  current form are a Linuxism.  Solaris has SO_RECVUCRED, an opaque ucred_t
  with opaque accessor functions (cf. ucred_get(3C) and getpeerucred(3C)).

  Rainer


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
@ 2013-02-02 15:40 ` ian at gcc dot gnu.org
  2013-02-02 15:41 ` ian at airs dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ian at gcc dot gnu.org @ 2013-02-02 15:40 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #1 from ian at gcc dot gnu.org <ian at gcc dot gnu.org> 2013-02-02 15:40:20 UTC ---
Author: ian
Date: Sat Feb  2 15:40:14 2013
New Revision: 195686

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195686
Log:
    PR go/56171
syscall: Only run creds_test on GNU/Linux.

Modified:
    trunk/libgo/Makefile.am
    trunk/libgo/Makefile.in
    trunk/libgo/testsuite/gotest


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
  2013-02-02 15:40 ` [Bug go/56171] " ian at gcc dot gnu.org
@ 2013-02-02 15:41 ` ian at airs dot com
  2013-02-07 17:03 ` ro at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ian at airs dot com @ 2013-02-02 15:41 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

Ian Lance Taylor <ian at airs dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #2 from Ian Lance Taylor <ian at airs dot com> 2013-02-02 15:40:39 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
  2013-02-02 15:40 ` [Bug go/56171] " ian at gcc dot gnu.org
  2013-02-02 15:41 ` ian at airs dot com
@ 2013-02-07 17:03 ` ro at gcc dot gnu.org
  2013-02-07 17:07 ` ro at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ro at gcc dot gnu.org @ 2013-02-07 17:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2013-02-07
         Resolution|FIXED                       |
   Target Milestone|---                         |4.8.0
     Ever Confirmed|0                           |1

--- Comment #3 from Rainer Orth <ro at gcc dot gnu.org> 2013-02-07 17:02:35 UTC ---
The test still doesn't pass on Solaris for a couple of reasons:

* passfd_test.go still uses AF_LOCAL which is missing on Solaris 9 and 10.  I'm
  attaching a patch that defines it from AF_UNIX if missing.

* Once it compiles, the test fails to link before Solaris 11:

Undefined                       first referenced
 symbol                             in file
nanosleep                           _gotest_.o  (symbol belongs to implicit
depe
ndency /lib/librt.so.1)
ld: fatal: symbol referencing errors. No output written to a.out
collect2: error: ld returned 1 exit status
FAIL: syscall

  We need two things to fix this: also check for nanosleep in librt, just as we
  do for sched_yield, and add $(LIBS) to GOLIBS so testcases are also linked
with
  -lrt if necessary.  The attached patch also handles this.

After those changes, the testcase compiles and links, but still fails:

--- FAIL: TestPassFD (0.11 seconds)
:0:     child process: "WriteMsgUnix: write unix: bad file number", <nil>
FAIL
FAIL: syscall

In truss, it seems the same fds (4, 5) are closed twice, yielding EBADF
the second time.  For fd 4, I found those stacktraces when the closes happen:

  12   4387                     close:return fd = 4 errno = 0

              libc.so.1`__close+0x7
              a.out`syscall.Close+0x1b
              libgo.so.3.0.1`os.close.pN7_os.file+0x5d
              libgo.so.3.0.1`os.Close.pN7_os.File+0x2a
              a.out`syscall_test.$thunk4+0x2a
              libgo.so.3.0.1`runtime.Goexit+0x42
              libgo.so.3.0.1`testing.FailNow.pN14_testing.common+0x22
              libgo.so.3.0.1`testing.Fatalf.pN14_testing.common+0x65
              a.out`syscall_test.TestPassFD+0xd77
              libgo.so.3.0.1`testing.$thunk10+0xe2
              libgo.so.3.0.1`kickoff+0x39
              libc.so.1`resumecontext
              libgo.so.3.0.1`testing.RunTests+0x461
              libgo.so.3.0.1`testing.Main+0x470
              a.out`main.main+0x63
              libgo.so.3.0.1`runtime_main+0x7b
              libgo.so.3.0.1`kickoff+0x39
              libc.so.1`resumecontext
              a.out`main+0x4b
              a.out`_start+0x83

  12   4387                     close:return fd = 4 errno = 9

              libc.so.1`__close+0x7
              a.out`syscall.Close+0x1b
              a.out`syscall_test.$thunk2+0x2a
              libgo.so.3.0.1`runtime.Goexit+0x42
              libgo.so.3.0.1`testing.FailNow.pN14_testing.common+0x22
              libgo.so.3.0.1`testing.Fatalf.pN14_testing.common+0x65
              a.out`syscall_test.TestPassFD+0xd77
              libgo.so.3.0.1`testing.$thunk10+0xe2
              libgo.so.3.0.1`kickoff+0x39
              libc.so.1`resumecontext
              libgo.so.3.0.1`testing.RunTests+0x461
              libgo.so.3.0.1`testing.Main+0x470
              a.out`main.main+0x63
              libgo.so.3.0.1`runtime_main+0x7b
              libgo.so.3.0.1`kickoff+0x39
              libc.so.1`resumecontext
              a.out`main+0x4b
              a.out`_start+0x83

I haven't yet made the necessary connections to the code to explain this.

  Rainer
In


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-02-07 17:03 ` ro at gcc dot gnu.org
@ 2013-02-07 17:07 ` ro at gcc dot gnu.org
  2013-02-11 19:03 ` ian at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ro at gcc dot gnu.org @ 2013-02-07 17:07 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #4 from Rainer Orth <ro at gcc dot gnu.org> 2013-02-07 17:06:27 UTC ---
Created attachment 29387
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29387
proposed patch

2013-02-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

    PR go/56171
    * mksysinfo.sh (AF_LOCAL): Provide via AF_UNIX if missing.

    * configure.ac: Check for nanosleep in librt.
    * configure: Regenerate.

    * Makefile.am (CHECK): Add $(LIBS) to GOLIBS.
    * Makefile.in: Regenerate.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-02-07 17:07 ` ro at gcc dot gnu.org
@ 2013-02-11 19:03 ` ian at gcc dot gnu.org
  2013-02-11 19:16 ` ian at airs dot com
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ian at gcc dot gnu.org @ 2013-02-11 19:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #5 from ian at gcc dot gnu.org <ian at gcc dot gnu.org> 2013-02-11 19:03:09 UTC ---
Author: ian
Date: Mon Feb 11 19:03:04 2013
New Revision: 195950

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195950
Log:
    PR go/56171
libgo: Solaris portability for syscall package.

>From Rainer Orth.

Modified:
    trunk/libgo/Makefile.am
    trunk/libgo/Makefile.in
    trunk/libgo/configure
    trunk/libgo/configure.ac
    trunk/libgo/mksysinfo.sh


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-02-11 19:03 ` ian at gcc dot gnu.org
@ 2013-02-11 19:16 ` ian at airs dot com
  2013-02-12 14:44 ` ro at CeBiTec dot Uni-Bielefeld.DE
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ian at airs dot com @ 2013-02-11 19:16 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #6 from Ian Lance Taylor <ian at airs dot com> 2013-02-11 19:16:41 UTC ---
The two closes of file descriptor 4 that you show are actually normal and
expected for this test.  The first is the deferred close of the os.File that
wraps the file descriptor, created by a call to os.NewFile.  The second is the
deferred close of the file descriptor itself.  The second close is deferred to
make sure that it happens even if os.NewFile fails.

Both closes are happening after the WriteMsgUnix failure.

Note that this test case execs itself in a separate process, so when using
truss you need to trace both processes to see what is happening.  The
WriteMsgUnix failure is happening in the child process.  It indicates that
sendmsg is returning an EBADF errno value, but I don't know why.

One place to look would be the function UnixRights in syscall/sockcmsg_unix.go.
 Is that the right format for passing a file descriptor on Solaris?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-02-11 19:16 ` ian at airs dot com
@ 2013-02-12 14:44 ` ro at CeBiTec dot Uni-Bielefeld.DE
  2013-02-12 15:02 ` ian at airs dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ro at CeBiTec dot Uni-Bielefeld.DE @ 2013-02-12 14:44 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #7 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> 2013-02-12 14:43:41 UTC ---
> --- Comment #6 from Ian Lance Taylor <ian at airs dot com> 2013-02-11
> 19:16:41 UTC ---
[...]
> Note that this test case execs itself in a separate process, so when using
> truss you need to trace both processes to see what is happening.  The
> WriteMsgUnix failure is happening in the child process.  It indicates that
> sendmsg is returning an EBADF errno value, but I don't know why.
>
> One place to look would be the function UnixRights in syscall/sockcmsg_unix.go.
>  Is that the right format for passing a file descriptor on Solaris?

It turned out that there was a mismatch between configure.ac which
defines -D_XOPEN_SOURCE=500 for Solaris, and libcalls.go: the latter has
e.g.

//extern sendmsg

but according to <sys/socket.h>, we need

#ifdef    _XPG4_2
#ifdef    __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname bind __xnet_bind
#pragma redefine_extname connect __xnet_connect
#pragma redefine_extname recvmsg __xnet_recvmsg
#pragma redefine_extname sendmsg __xnet_sendmsg
#pragma redefine_extname sendto __xnet_sendto
#pragma redefine_extname socket __xnet_socket
#pragma redefine_extname socketpair __xnet_socketpair
#pragma redefine_extname getsockopt __xnet_getsockopt

Depending on whether sendmsg or __xnet_sendmsg is used, the kernel
expects different variants of struct msghdr.

I hacked around this by manually adapting libcalls.go to use the __xnet_
forms, which allowed the test to pass.  I've not yet checked what's the
best way to handle this properly.

    Rainer


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-02-12 14:44 ` ro at CeBiTec dot Uni-Bielefeld.DE
@ 2013-02-12 15:02 ` ian at airs dot com
  2013-02-14 10:11 ` ro at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ian at airs dot com @ 2013-02-12 15:02 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #8 from Ian Lance Taylor <ian at airs dot com> 2013-02-12 15:02:12 UTC ---
I think we'll need to pull the relevant //sys lines out of socket.go into,
e.g., socket_posix.go, and then add socket_xnet.go, and arrange for the
Makefile to choose between them based on LIBGO_IS_SOLARIS.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2013-02-12 15:02 ` ian at airs dot com
@ 2013-02-14 10:11 ` ro at gcc dot gnu.org
  2013-02-20 20:05 ` ian at gcc dot gnu.org
  2013-02-20 20:06 ` ian at airs dot com
  10 siblings, 0 replies; 12+ messages in thread
From: ro at gcc dot gnu.org @ 2013-02-14 10:11 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #9 from Rainer Orth <ro at gcc dot gnu.org> 2013-02-14 10:11:11 UTC ---
Created attachment 29448
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29448
proposed patch for __xnet_ socket functions

This works fine in the 32-bit case, but for 64-bit (both sparc and x86) needed
one further adjustment: the 64-bit tests were failing like this:

  amd64:

--- FAIL: TestPassFD (0.09 seconds)
:0:     child process ReadAll: "", <nil>; want "Hello from child process!\n"
FAIL
FAIL: syscall

  sparcv9:

--- FAIL: TestPassFD (0.28 seconds)
passfd_test.go:102:     child process ReadAll: "", <nil>; want "Hello from
child process!\n"
FAIL
FAIL: syscall

(Btw., need to check why filename and line number aren't detected on x86...)

It turned out that as on Darwin, we always need 32-bit alignment.  The attached
patch does just that and allows the syscall to pass on both 32- and 64-bit
Solaris/SPARC and x86.

  Rainer

2013-02-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

    PR go/5617
    * go/syscall/sockcmsg_unix.go: Import "runtime".
    (cmsgAlignOf): Enforce 32-bit alignment on Solaris.
    * go/syscall/socket.go (bind, connect, socket, socketpair)
    (getsockopt, sendto, recvmsg, sendmsg): Move ...
    * go/syscall/socket_posix.go: ... here.
    New file.
    * go/syscall/socket_xnet.go: New file.
    * Makefile.am (syscall_socket_os_file): New variable.
    (go_base_syscall_files): Use it.
    * Makefile.in: Regenerate.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2013-02-14 10:11 ` ro at gcc dot gnu.org
@ 2013-02-20 20:05 ` ian at gcc dot gnu.org
  2013-02-20 20:06 ` ian at airs dot com
  10 siblings, 0 replies; 12+ messages in thread
From: ian at gcc dot gnu.org @ 2013-02-20 20:05 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

--- Comment #10 from ian at gcc dot gnu.org <ian at gcc dot gnu.org> 2013-02-20 20:04:48 UTC ---
Author: ian
Date: Wed Feb 20 20:04:36 2013
New Revision: 196180

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196180
Log:
    PR go/56171
syscall: Solaris fixes for passing file descriptor.

>From Rainer Orth.

Added:
    trunk/libgo/go/syscall/socket_posix.go
    trunk/libgo/go/syscall/socket_xnet.go
Modified:
    trunk/libgo/Makefile.am
    trunk/libgo/Makefile.in
    trunk/libgo/go/syscall/sockcmsg_unix.go
    trunk/libgo/go/syscall/socket.go


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug go/56171] syscall FAILs on Solaris
  2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2013-02-20 20:05 ` ian at gcc dot gnu.org
@ 2013-02-20 20:06 ` ian at airs dot com
  10 siblings, 0 replies; 12+ messages in thread
From: ian at airs dot com @ 2013-02-20 20:06 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56171

Ian Lance Taylor <ian at airs dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #11 from Ian Lance Taylor <ian at airs dot com> 2013-02-20 20:06:04 UTC ---
Fixed again.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-02-20 20:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-01 12:05 [Bug go/56171] New: syscall FAILs on Solaris ro at gcc dot gnu.org
2013-02-02 15:40 ` [Bug go/56171] " ian at gcc dot gnu.org
2013-02-02 15:41 ` ian at airs dot com
2013-02-07 17:03 ` ro at gcc dot gnu.org
2013-02-07 17:07 ` ro at gcc dot gnu.org
2013-02-11 19:03 ` ian at gcc dot gnu.org
2013-02-11 19:16 ` ian at airs dot com
2013-02-12 14:44 ` ro at CeBiTec dot Uni-Bielefeld.DE
2013-02-12 15:02 ` ian at airs dot com
2013-02-14 10:11 ` ro at gcc dot gnu.org
2013-02-20 20:05 ` ian at gcc dot gnu.org
2013-02-20 20:06 ` ian at airs dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).