[Lldb-commits] [PATCH] D41086: [lldb] Check that a regex is valid before searching by regex for a symbol in a pdb.

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 11 12:59:54 PST 2017


zturner added inline comments.


================
Comment at: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp:392-399
+  bool is_regex = false;
+  if (name_str.find_first_of("[]?*.-+\\") != std::string::npos) {
+    // Trying to compile an invalid regex could throw an exception.
+    // Only search by regex when it's valid.
+    lldb_private::RegularExpression name_regex(name_str);
+    is_regex = name_regex.IsValid();
+  }
----------------
I can see two possible problems here.

1. Now if it is a valid regex, it's going to compile it twice, hurting performance (not sure by how much, it could be negligible)

2. Whether or not it's valid is determined by asking LLDB's regex engine, but it's then compiled with C++ STL's engine.  It's possible they won't agree on whether or not a regex is valid.

You mentioned that it throws an exception on an invalid regex.  What actually happens though?  Because we compile with exception support disabled.  Does it terminate the program?

At a minimum, the validity check and the find function should agree on the regex engine.  If the only way to make that work is to change from `std::regex` to `lldb_private::RegularExpression` as the matching engine, then I guess we have to do that.


Repository:
  rL LLVM

https://reviews.llvm.org/D41086





More information about the lldb-commits mailing list