<regex>: regex_search() throws regex_error(error_complexity) when a long string is used with a lookahead regex

Đang mở
#6,347 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

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
45/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Ít trao đổi
Công nghệ
cpp
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu bằng cách chạy trình tái hiện dòng lệnh C++ được cung cấp với đường dẫn dài và regex_search(), sử dụng môi trường MSVC 19.51 được báo cáo. Theo dõi cách std::regex_search xử lý mẫu này và kết quả regex_error(error_complexity), sau đó xác minh rằng trình tái hiện hoàn tất mà không xảy ra ngoại lệ, đồng thời duy trì hành vi khớp mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug regex

Describe the bug

We a trying to upgrade the compiler to the latest MSVC version. First time we did hit this issue #5792. After it was fixed and new MSVC version published, we've upgraded again to 14.51 and now we are getting another issue, this time with regex_error(error_complexity) when a lookahead regex is being used with a really long search string.

Note that if I make the path string shorter, everything is working good. While this might be an expected limitation, we didn't have issues with Visual Studio 2022. Also on Linux with GCC 13 this code is working properly.

Command-line test case

#include <iostream>
#include <regex>

int main()
{
	try {
		std::regex pattern(R"((?:.+[\/\\])?(?:.+?)_(.+?)_(.+?)@(.+?)\.(?:exe|app))");
		std::smatch matches;
		std::string requestStringParams(R"(D:\some\really\long\path\dir\dir\dir\dir\dir\dir\dir\dir\dir\dir\dir\dir\dir\dir\dir\dir\myapp.exe https://mysite.com/doaction/?action=56)");
		std::regex_search(requestStringParams, matches, pattern);
		std::cout << "no exception\n";
	}
	catch (const std::regex_error& ex) {
		std::cout << "regex_error with code " << ex.code() << "\n";
	}

	return 0;
}

This prints "regex_error with code 11".

Expected behavior

Should print "no exception".

STL version

Microsoft (R) C/C++ Optimizing Compiler Version 19.51.36248 for x64

Additional context

Might be related to issue #5792 but the exception is with different error code.

Ngôn ngữ chính
C++
Star
11.2k
Fork
1.7k
Merge trung bình
4 ngày 4 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/STL

Tất cả issue của microsoft/STL

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.