-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
runtime: goroutine not starting #57394
Comments
This is an unsynchronized program, there is no guarantee on goroutine scheduling ordering or execution before program exit. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For questions please refer to https://github.com/golang/go/wiki/Questions |
@seankhliao, no, no, I think You are inattentive. If the problem was in the simple synchronization of goroutines, then we would see the following output:
There is also the main loop, which should work in the method, regardless of the goroutines. And pay attention to the last message If you don't like my simple example, here are two more with a similar problem. The first with goroutine synchronization, the second with http package.
main.gopackage main
/*
#include <security/pam_modules.h>
typedef const char cchar_t;
*/
import "C"
import (
"log"
"sync"
)
func main() {}
//export pam_sm_authenticate
func pam_sm_authenticate(pamh *C.pam_handle_t, flags C.int, argc C.int, argv **C.cchar_t) C.int {
log.Printf("golib.so: begin")
defer log.Printf("golib.so: end")
var wg sync.WaitGroup
wg.Add(1)
go func(wg *sync.WaitGroup) {
log.Printf("golib.so: this message will not be printed")
wg.Done()
}(&wg)
wg.Wait()
return C.PAM_SUCCESS
} Output:
main.gopackage main
/*
#include <security/pam_modules.h>
typedef const char cchar_t;
*/
import "C"
import (
"log"
"net/http"
"time"
)
func main() {}
//export pam_sm_authenticate
func pam_sm_authenticate(pamh *C.pam_handle_t, flags C.int, argc C.int, argv **C.cchar_t) C.int {
log.Printf("golib.so: begin")
defer log.Printf("golib.so: end")
client := http.Client{
Timeout: 1 * time.Second,
}
client.Get("http://github.com")
log.Printf("golib.so: this message will not be printed")
return C.PAM_SUCCESS
} Please, don't tell me to check the network settings!
Trouble starting goroutine, ssh somehow breaks golang goroutine scheduler. But I dont know how. |
then probably ssh is opening the module, then forking, which breaks see #15538 |
Thanks @seankhliao! This information helped in understanding the cause of the problem! 🙏 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
First of all sorry for my english.
I wrote PAM module on Golang, but when I connect by ssh, pam starts and module stuck. Stuck on
http
package indialConnFor
which is called as a goroutine in linetransport.go
.Minimal project for reproduce issue:
sudo apt install libpam0g-dev
main.go
Dockerfile
docker-compose.yml
go build --buildmode=c-shared -o golib.so ./
sudo docker-compose build
sudo docker-compose up
ssh -p 2222 any@localhost
What did you expect to see?
What did you see instead?
First terminal:
Output:
Then, in second terminal try connect to container:
In first terminal you can see logs from go module and stucking, then sshd (or pam) timeout message:
Help me please, why goroutine not starting?
I was looking for issues with the same keywords and this might be issue #44176?
p.s.
socketpair
call ssh_msg_recv
debug3: ssh_msg_recv entering
Thank you for your attention!
The text was updated successfully, but these errors were encountered: