Catastrophic Backtracking while using `Binds`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với MOUNT_WIN_REGEX trong iotedgehubdev/compose_parser.py và MOUNT_MODE_REGEX trong iotedgehubdev/constants.py, sau đó tái hiện thời gian thực thi đã được báo cáo bằng các Windows bind mount có độ sâu tăng dần. Theo dõi cách createOptions áp dụng các mẫu và xác minh rằng các đường dẫn hợp lệ có chữ cái viết hoa không còn có thời gian matching tăng theo hàm mũ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Trying to use Binds in createOptions (binding Windows directory to Linux container) seems to raise catastrophic backtracking. The pattern responsible is MOUNT_WIN_REGEX
https://github.com/Azure/iotedgehubdev/blob/7eede7286a0603e565c8b183d090f2585521aae6/iotedgehubdev/compose_parser.py#L190
The following is the result of applying MOUNT_WIN_REGEX on different binds:
C:/:/app/ took 0.009343099998659454
C:/Folder1/:/app/ took 0.00018330000239075162
C:/Folder1/Folder2/:/app/ took 0.003711700002895668
C:/Folder1/Folder2/Folder3/:/app/ took 0.28317089999836753
C:/Folder1/Folder2/Folder3/Folder4/:/app/ took 18.772531900001923
as you can see, runtime grows exponentially. The fifth depth didn't return any result even after 5 minutes. This is the code I ran:
bind = "C:/"
counter = 1
def match(bind):
return regex.match(MOUNT_WIN_REGEX, bind)
while counter < 10:
result = timeit.timeit(lambda: match(f"{bind}:/app/"), number=1)
print(f"{bind}:/app/ took {result}")
bind += f"Folder{counter}/"
counter += 1
The reason seems to be the inline modifier (?i) in MOUNT_MODE_REGEX:
https://github.com/Azure/iotedgehubdev/blob/7eede7286a0603e565c8b183d090f2585521aae6/iotedgehubdev/constants.py#L48
The modifier somehow is propagated to the whole pattern. Removing the modifier will solve the catastrophic backtracking, but the pattern won't match paths with capital letters. By including the range A-Z in the pattern, the issue of backtracking resurfaces.
Suggestions:
- split the bind string by
:, and apply smaller patterns on split strings instead of applying the huge regex patterns on the whole string - instead of applying two huge regex patterns, break them up and use
if-eliffor pattern matching
- Ngôn ngữ chính
- Python
- Star
- 91
- Fork
- 38
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
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 Azure/iotedgehubdev
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
Azure/iotedgehubdev#416 · 1 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Azure/iotedgehubdev#415 ·
-
Not able to installĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Azure/iotedgehubdev#413 · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Azure/iotedgehubdev#412 · 1 bình luận ·
-
bug InBacklog
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
Azure/iotedgehubdev#398 · 2 bình luận ·
Tất cả issue của Azure/iotedgehubdev
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
aws-samples/sample-per-model-bedrock#243 ·
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 66/100
FuRongJun-1999/dsh-memory#404 ·
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 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PennyLaneAI/catalyst#3337 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Workflow.schedule stops when a cron deadline passes before sleepCó thể đã có người làm @HuaTNA đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày