View Issue Details

IDProjectCategoryView StatusLast Update
0001753Anope Stable (2.0.x series)Generalpublic2023-01-13 07:04
Reporterthesamesam Assigned To 
Status newResolutionopen 
Summary0001753: CMake module parsing logic is brittle, breaks with CLICOLOR_FORCE=1
DescriptionHi folks,

When building Anope (2.0.12, but happens with earlier versions too) with the PCRE2 module configured, I get the following output:
-- Looking for kqueue
-- Looking for kqueue - not found
CMake Error at cmake/Anope.cmake:477 (message):

  needs library /*; *; * (C) 2012-2022 Anope Team; * Contact us at; *; * Please read COPYING and README for further details.;
  */;;libpcre2-8;;#include "module.h";;#define PCRE2_CODE_UNIT_WIDTH
  8;#include <pcre2.h>;;class PCRERegex : public Regex;{; pcre2_code
  *regex;;; public:; PCRERegex(const Anope::string &expr) :
  Regex(expr); {; int errcode;; PCRE2_SIZE erroffset;; this->regex =
  pcre2_compile(reinterpret_cast<PCRE2_SPTR8>(expr.c_str()); expr.length();
  PCRE2_CASELESS; &errcode; &erroffset; NULL);;; if
  (!this->regex); {; PCRE2_UCHAR
  error[128];; pcre2_get_error_message(errcode; error; sizeof
  error);; throw RegexException("Error in regex " + expr + " at offset " +
  stringify(erroffset) + ": " + reinterpret_cast<const
  char*>(error));; }; };; ~PCRERegex(); {; pcre2_code_free(this->regex);; };; bool
  Matches(const Anope::string &str); {; pcre2_match_data *unused =
  pcre2_match_data_create_from_pattern(this->regex; NULL);; int result =
  pcre2_match(regex; reinterpret_cast<PCRE2_SPTR8>(str.c_str());
  str.length(); 0; 0; unused;
  NULL);; pcre2_match_data_free(unused);; return result >= 0;; };};;;class
  PCRERegexProvider : public RegexProvider;{;
  public:; PCRERegexProvider(Module *creator) : RegexProvider(creator;
  "regex/pcre") { };; Regex *Compile(const Anope::string &expression)
  anope_override; {; return new PCRERegex(expression);; };};;;class
  ModuleRegexPCRE : public Module;{; PCRERegexProvider pcre_regex_provider;;;
  public:; ModuleRegexPCRE(const Anope::string &modname; const Anope::string
  &creator) : Module(modname; creator; EXTRA but we were unable to locate
  that library! Check that the library is within the search path of your OS.
Call Stack (most recent call first):
  modules/CMakeLists.txt:40 (calculate_libraries)
  modules/CMakeLists.txt:169 (build_modules)

-- Configuring incomplete, errors occurred!
See also "/var/tmp/portage/net-irc/anope-2.0.12/work/anope-2.0.12_build/CMakeFiles/CMakeOutput.log".
See also "/var/tmp/portage/net-irc/anope-2.0.12/work/anope-2.0.12_build/CMakeFiles/CMakeError.log".
[EE] ERROR: net-irc/anope-2.0.12::gentoo failed (configure phase):
[EE] cmake failed

For a while, CMake ended up segfaulting for me at this point, but it doesn't anymore. I reported to them and while they couldn't reproduce the segfault, they did conclude that there was something wrong with Anope's use of CMake.

Brad King analysed it at
anope's CMakeLists.txt file here.

- does some non-standard version check logic instead of just using CMAKE_VERSION, and ends up thinking that the running version of CMake is older than 2.6.
- anope takes this pre-2.6 code path to read files with a cmake -P .../ReadFile.cmake helper script.
- anope tries reading a file that doesn't exist, and the resulting error message is captured as if it were the content of the file.
- With CLICOLOR_FORCE, the error message has vt100 escape sequences in it.
- anope then continues as if the file existed and had the vt100 escape sequences in its content, and gets confused.
Steps To ReproduceThe Dockerfile at is sufficient.
TagsNo tags attached.


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2023-01-13 07:04 thesamesam New Issue