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

nativeGetPortsList hangs for 30 seconds on unix.Close(port.handle) #104

Open
dstahlke opened this issue Mar 7, 2021 · 1 comment
Open

Comments

@dstahlke
Copy link

dstahlke commented Mar 7, 2021

This happens for me on Linux when trying to upload an Arduino sketch using arduino-cli. When nativeGetPortsList opens /dev/ttyS0, then closes it, the close syscall hangs for 30 seconds. As soon as the close syscall starts, /dev/ttyS0 disappears from /proc/$(pgrep arduino-cli)/fd. But the syscall doesn't return for 30 seconds. Stack trace:

#0  syscall.Syscall () at /usr/lib/go-1.13/src/syscall/asm_linux_amd64.s:27
#1  0x000000000062f7a0 in golang.org/x/sys/unix.Close (fd=3, err=...) at /home/XXX/go/pkg/mod/golang.org/x/sys@v0.0.0-20200909081042-eff7692f9009/unix/zsyscall_linux.go:525
#2  0x0000000000d5343c in (*unixPort).Close (port=0xc00406dd10, ~r0=...) at /home/XXX/go/pkg/mod/go.bug.st/serial@v1.1.2/serial_unix.go:37
#3  0x0000000000d547e1 in st/serial.nativeGetPortsList (~r0=..., ~r1=...) at /home/XXX/go/pkg/mod/go.bug.st/serial@v1.1.2/serial_unix.go:249
#4  0x0000000000d558d7 in st/serial.GetPortsList () at /home/XXX/go/pkg/mod/go.bug.st/serial@v1.1.2/serial.go:63
#5  github.com/arduino/arduino-cli/arduino/serialutils.WaitForNewSerialPort.func1 (~r0=<optimized out>, ~r1=...) at /home/XXX/Desktop/arduino-cli/arduino/serialutils/serialutils.go:95
#6  0x0000000000d5568f in github.com/arduino/arduino-cli/arduino/serialutils.WaitForNewSerialPort (~r0=..., ~r1=...) at /home/XXX/Desktop/arduino-cli/arduino/serialutils/serialutils.go:106
#7  0x0000000000d55536 in github.com/arduino/arduino-cli/arduino/serialutils.WaitForNewSerialPortOrDefaultTo (defaultPort=..., ~r1=..., ~r2=...)
    at /home/XXX/Desktop/arduino-cli/arduino/serialutils/serialutils.go:78
#8  0x0000000000d58b4b in github.com/arduino/arduino-cli/commands/upload.runProgramAction (pm=0xc00038d480, sketch=0xc003e420c0, importFile=..., importDir=..., fqbnIn=..., port=..., programmerID=..., 
    verbose=false, verify=false, burnBootloader=false, outStream=..., errStream=..., ~r12=...) at /home/XXX/Desktop/arduino-cli/commands/upload/upload.go:328
#9  0x0000000000d56c27 in github.com/arduino/arduino-cli/commands/upload.Upload (ctx=..., req=0xc00058fcd0, outStream=..., errStream=..., ~r4=<optimized out>, ~r5=...)
    at /home/XXX/Desktop/arduino-cli/commands/upload/upload.go:56
#10 0x0000000000e13b90 in github.com/arduino/arduino-cli/cli/upload.run (command=<optimized out>, args=...) at /home/XXX/Desktop/arduino-cli/cli/upload/upload.go:95
#11 0x00000000009609ca in github.com/spf13/cobra.(*Command).execute (c=0xc000421340, a=..., err=...) at /home/XXX/go/pkg/mod/github.com/spf13/cobra@v1.0.1-0.20200710201246-675ae5f5a98c/command.go:846
#12 0x00000000009616a9 in github.com/spf13/cobra.(*Command).ExecuteC (c=0xc000421340, cmd=<optimized out>, err=...)
    at /home/XXX/go/pkg/mod/github.com/spf13/cobra@v1.0.1-0.20200710201246-675ae5f5a98c/command.go:950
#13 0x0000000000e16b65 in github.com/spf13/cobra.(*Command).Execute (c=<optimized out>) at /home/XXX/go/pkg/mod/github.com/spf13/cobra@v1.0.1-0.20200710201246-675ae5f5a98c/command.go:887
#14 main.main () at /home/XXX/Desktop/arduino-cli/main.go:31

If I run cat /dev/ttyS0 from another terminal, this hang doesn't happen.

@cmaglie
Copy link
Member

cmaglie commented Sep 6, 2021

Is the port a USB port of the Arduino board? or is it an USB-to-Serial adapter connected to the Arduino? Which board is?

Please write here the full go source code that reproduce the problem (possibly try to cut it down to the minimum needed to reproduce the issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants