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

os/user: doesn't work with musl libc #11319

Closed
dominikh opened this issue Jun 21, 2015 · 14 comments
Closed

os/user: doesn't work with musl libc #11319

dominikh opened this issue Jun 21, 2015 · 14 comments

Comments

@dominikh
Copy link
Member

When building Go on Linux with musl instead of glibc, os/user doesn't work:

$ go test os/user
--- FAIL: TestCurrent (0.00s)
user_test.go:23: Current: user: unreasonable _SC_GETPW_R_SIZE_MAX of -1
--- FAIL: TestLookup (0.00s)
user_test.go:64: Current: user: unreasonable _SC_GETPW_R_SIZE_MAX of -1
--- FAIL: TestLookupId (0.00s)
user_test.go:82: Current: user: unreasonable _SC_GETPW_R_SIZE_MAX of -1

That's because Go assumes that on Linux, _SC_GETPW_R_SIZE_MAX will always be >0, which isn't true.

I have a fix for this ready. Is this something for Go 1.5, or should I wait till 1.6?

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jul 11, 2015
@ianlancetaylor
Copy link
Contributor

At this point, let's wait for 1.6.

@dominikh
Copy link
Member Author

I figured as much.

@gopherbot
Copy link

CL https://golang.org/cl/13772 mentions this issue.

@mikioh mikioh modified the milestones: Go1.6, Unplanned Aug 22, 2015
@somasis
Copy link

somasis commented Dec 4, 2015

I'm still hitting this issue with musl-1.1.12, and go-1.5.2, bootstrapping from go-1.4.3.

# os/user
os/user/lookup_unix.go:70: cannot use C.ulong(bufSize) (type C.ulong) as type C.size_t in argument to _Cfunc__CMalloc
os/user/lookup_unix.go:83: cannot use C.ulong(bufSize) (type C.ulong) as type C.size_t in argument to _Cfunc_mygetpwnam_r
os/user/lookup_unix.go:98: cannot use C.ulong(bufSize) (type C.ulong) as type C.size_t in argument to _Cfunc_mygetpwuid_r

@bradfitz
Copy link
Contributor

bradfitz commented Dec 4, 2015

It'll be in Go 1.6. 1.5.x is only for critical things, not nice to haves.

@dominikh
Copy link
Member Author

dominikh commented Dec 4, 2015

What @somasis is reporting looks like a separate issue to me.

@somasis
Copy link

somasis commented Dec 4, 2015

I should have said, I actually patched go-1.5.2 with the commit related to this issue, and still hit that error.

@Thomasdezeeuw
Copy link
Contributor

@somasis Have you tried tip (latest development version)?

@somasis
Copy link

somasis commented Dec 6, 2015

@Thomasdezeeuw Yes, I get the same error.

# os/user
os/user/lookup_unix.go:67: cannot use C.ulong(bufSize) (type C.ulong) as type C.size_t in argument to _Cfunc__CMalloc
os/user/lookup_unix.go:80: cannot use C.ulong(bufSize) (type C.ulong) as type C.size_t in argument to _Cfunc_mygetpwnam_r
os/user/lookup_unix.go:95: cannot use C.ulong(bufSize) (type C.ulong) as type C.size_t in argument to _Cfunc_mygetpwuid_r

@somasis
Copy link

somasis commented Dec 10, 2015

I managed to get the latest git master to build with CGO_ENABLED=0 passed to the final ./make.bash. That doesn't sound like the right solution, though.

@somasis
Copy link

somasis commented Dec 10, 2015

...which then fails to build programs such as syncthing, because of the exact same error.

@andlabs
Copy link
Contributor

andlabs commented Jan 19, 2016

@somasis the compile errors you pasted are unrelated to this issue and are possibly a bug in cgo. If there isn't a similar issue already filed, you should file a new one. In fact, they may rely on another fix that was already applied to 1.6; you may as well try with the betas or with master first.

ncopa pushed a commit to alpinelinux/aports that referenced this issue Feb 23, 2016
Including patch to fix 386 build.
golang/go#14476

Removed default-sc-getpw-r-size-max.patch, fixed upstream.
golang/go#11319

Changed the offset for no-pic.patch to match new code.

TT: pkgrel set to 1 as the original pkgrel=0 failed to build
with x86 and was reverted.
@williamh
Copy link

Is this still an issue in Go 1.6? I'm hearing concerns about musl in Gentoo [1].

[1] https://bugs.gentoo.org/show_bug.cgi?id=575510#C1

@ianlancetaylor
Copy link
Contributor

@williamh This issue is closed as fixed in 1.6. Please take any questions about it to a forum; see https://golang.org/wiki/Questions . Thanks.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
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

9 participants