USB: unexpected heap allocations at -opt=0
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Reproduce the failure with tinygo build -target=pico -scheduler=none -opt=0 -gc=none -o out.elf ., then inspect src/machine/machine_rp2_usb.go and src/machine/usb/cdc/usbcdc.go around the reported allocations. Check comparable USB implementations on other targets and review the escape-analysis and stack-usage discussion in related issues. Done means the Pico build no longer reports these heap allocations and the broader audit identifies any equivalent cases without excessive stack usage.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When building for RP2 targets with -opt=0 -gc=none, heap allocations in the USB implementation cause build failures.
The clock initialization part of this was reported in #6613 and fixed by #6635, but the USB-related allocations remain.
Reproduce
package main
func main() {}
$ tinygo build -target=pico -scheduler=none -opt=0 -gc=none -o out.elf .
src/machine/machine_rp2_usb.go:108: object allocated on the heap with -gc=none
src/machine/usb/cdc/usbcdc.go:232: object allocated on the heap with -gc=none
Known allocations
src/machine/machine_rp2_usb.go:108:var b [cdcLineInfoSize]byteinReceiveUSBControlPacketsrc/machine/usb/cdc/usbcdc.go:232: the array returned bymachine.ReceiveUSBControlPacket()incdcSetup(SET_LINE_CODING)
Both allocations involve local arrays that are sliced (b[:]) and passed to functions. At -opt=0, these allocations are not eliminated because escape analysis is not performed.
For comparison, the GET_LINE_CODING path uses the package-level cdcSetupBuff and does not allocate.
Since similar allocation patterns may exist in USB implementations for other targets, I would like to investigate this separately.
Scope
- Identify unnecessary heap allocations in USB implementations at
-opt=0. - Check whether other targets have similar allocations in their USB implementations.
- Determine an appropriate solution without introducing excessive stack usage.
Relation to #6645
This is related to #6645, but it remains to be determined whether enabling escape analysis at -opt=0 is sufficient to resolve the USB-related issues.
As noted in #6645, enabling escape analysis may also increase stack usage on Cortex-M, so USB-specific changes may still be necessary.
Environment: TinyGo dev (after #6635), target pico
- Ngôn ngữ chính
- Go
- Star
- 17.8k
- Fork
- 1.1k
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 380
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tinygo-org/tinygo
-
avr: SPI Mode2 runs as mode 1Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tinygo-org/tinygo#6727 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
tinygo-org/tinygo#6711 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Builds are not reproducible: cgo snippet paths in debug infoCó thể đã có người làm @tridev-tej đã nhận 1 ngày trước. Đang mởenhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tinygo-org/tinygo#6619 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix the targets that tinygo build -target rejectsCó thể đã có người làm @narguis đã nhận 2 ngày trước. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
tinygo-org/tinygo#6617 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
tinygo-org/tinygo#6312 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của tinygo-org/tinygo
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sresarehumantoo/cc-artex#456 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ollama/ollama#20021 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
factory:subtask
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
release
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
github/gh-aw-mcpg#17603 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
bboerst/stratum-work#351 ·
Maintainer thường phản hồi trong vòng 1 ngày