* [musl] SIGSEV error when using REGEX with musl library
@ 2021-11-25 14:53 Quesada Gonzalez, Elena
2021-11-25 15:52 ` Rich Felker
0 siblings, 1 reply; 4+ messages in thread
From: Quesada Gonzalez, Elena @ 2021-11-25 14:53 UTC (permalink / raw)
To: musl
[-- Attachment #1.1: Type: text/plain, Size: 2135 bytes --]
I have the following function that works fine if the regular expression is correct, but get a SIGSEGV when calling regex_search compiling with clang-9 and using musl 1.2.
However, it works fine with glibc,
Could be a bug in musl library?
Find code below
void CRuntimeCommandLine::LoadComplement(const multimap<std::string, std::string>& mapArguments)
{
// Find parameter
multimap<string, string>::const_iterator iter;
iter = mapArguments.find("Complement");
if(iter == mapArguments.end())
{
// Only fatal. Statement is not initialized yet.
Logger::fatal(Errors::RCMD_F005_MISSING_MANDATORY_PARAM, "Missing mandatory parameter --Complement");
}
// regex expression for system_secret to be checked (Max 4Bytes, hexadecimal number in lowe case letters and no 0x format)
regex regexp("^[0-9a-f]{1,8}$");
// regex_search that searches pattern regexp in the string mystr
std::string s = iter->second.c_str();
if (false == std::regex_search(s, regexp))
{
// Only fatal. Statement is not initialized yet.
Logger::fatal(Errors::RCMD_F006_INVALID_VALUE, "Invalid --Complement=hexvalue value");
}
else
{
// get hexadecimal value
(void)sscanf(s.c_str(), "%X", &(m_cmdParameters.complementValue));
}
}
With kind regards
Elena Quesada Gonzalez
Siemens Rail Automation S.A.U.
Mobility
Rail Infrastructure
DS3
SMO RI R&D ES PF 1
Ronda de Europa, 5
28760 Tres Cantos, Spain
Mobile: +34 686405648
mailto:elena.quesada_gonzalez@siemens.com
www.siemens.es
[cid:image001.gif@01D7E214.8C900130]
Siemens Rail Automation, S.A.U. A28512598. Ronda de Europa 5, Tres Cantos 28760 (Madrid). Hoja: M- 2.583, Tomo: 22716, Folio: 60.
Los datos que nos aporte o nos haya aportado son tratados por Siemens Rail Automation S.A.U. para atender su mensaje o, en su caso, prestarle el servicio que haya solicitado. Tiene derecho a acceder, rectificar, suprimir los datos y otros derechos, como se explica en la politica de privacidad.
www.siemens.com/es/es/home/informacion-corporativa/legal.html
[-- Attachment #1.2: Type: text/html, Size: 7918 bytes --]
[-- Attachment #2: image001.gif --]
[-- Type: image/gif, Size: 2730 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [musl] SIGSEV error when using REGEX with musl library
2021-11-25 14:53 [musl] SIGSEV error when using REGEX with musl library Quesada Gonzalez, Elena
@ 2021-11-25 15:52 ` Rich Felker
2021-11-26 11:46 ` Quesada Gonzalez, Elena
0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2021-11-25 15:52 UTC (permalink / raw)
To: Quesada Gonzalez, Elena; +Cc: musl
On Thu, Nov 25, 2021 at 02:53:13PM +0000, Quesada Gonzalez, Elena wrote:
> I have the following function that works fine if the regular expression is correct, but get a SIGSEGV when calling regex_search compiling with clang-9 and using musl 1.2.
> However, it works fine with glibc,
>
> Could be a bug in musl library?
>
>
> Find code below
>
> void CRuntimeCommandLine::LoadComplement(const multimap<std::string, std::string>& mapArguments)
> {
> // Find parameter
> multimap<string, string>::const_iterator iter;
> iter = mapArguments.find("Complement");
> if(iter == mapArguments.end())
> {
> // Only fatal. Statement is not initialized yet.
> Logger::fatal(Errors::RCMD_F005_MISSING_MANDATORY_PARAM, "Missing mandatory parameter --Complement");
> }
> // regex expression for system_secret to be checked (Max 4Bytes, hexadecimal number in lowe case letters and no 0x format)
> regex regexp("^[0-9a-f]{1,8}$");
>
> // regex_search that searches pattern regexp in the string mystr
> std::string s = iter->second.c_str();
> if (false == std::regex_search(s, regexp))
> {
> // Only fatal. Statement is not initialized yet.
> Logger::fatal(Errors::RCMD_F006_INVALID_VALUE, "Invalid --Complement=hexvalue value");
> }
> else
> {
> // get hexadecimal value
> (void)sscanf(s.c_str(), "%X", &(m_cmdParameters.complementValue));
> }
>
> }
> With kind regards
> Elena Quesada Gonzalez
Do you have a complete minimal-ish test case that can be compiled and
show the same thing happening? Even just a dummy main() to call the
above the way you expect it to be called?
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [musl] SIGSEV error when using REGEX with musl library
2021-11-25 15:52 ` Rich Felker
@ 2021-11-26 11:46 ` Quesada Gonzalez, Elena
2021-11-26 16:32 ` Alex Xu
0 siblings, 1 reply; 4+ messages in thread
From: Quesada Gonzalez, Elena @ 2021-11-26 11:46 UTC (permalink / raw)
To: Rich Felker; +Cc: musl
Hi,
A simple main with the following code, should replicate the error.
#include <regex>
void main()
{
std::regex regexp("^[a-z0-9]{1,8}$");
std::string s = ("0xAz10145274");
if (false == std::regex_search(s, regexp))
{
// Only fatal. Statement is not initialized yet.
printf("Invalid regex [%s]\n", __FUNCTION__);
exit(1);
}
else {
printf("Regex ok [%s]\n", __FUNCTION__);
}
}
Thanks for your time
-----Mensaje original-----
De: Rich Felker <dalias@libc.org>
Enviado el: jueves, 25 de noviembre de 2021 16:52
Para: Quesada Gonzalez, Elena (SMO RI R&D ES PF 1) <elena.quesada_gonzalez@siemens.com>
CC: musl@lists.openwall.com
Asunto: Re: [musl] SIGSEV error when using REGEX with musl library
On Thu, Nov 25, 2021 at 02:53:13PM +0000, Quesada Gonzalez, Elena wrote:
> I have the following function that works fine if the regular expression is correct, but get a SIGSEGV when calling regex_search compiling with clang-9 and using musl 1.2.
> However, it works fine with glibc,
>
> Could be a bug in musl library?
>
>
> Find code below
>
> void CRuntimeCommandLine::LoadComplement(const multimap<std::string,
> std::string>& mapArguments) {
> // Find parameter
> multimap<string, string>::const_iterator iter;
> iter = mapArguments.find("Complement");
> if(iter == mapArguments.end())
> {
> // Only fatal. Statement is not initialized yet.
> Logger::fatal(Errors::RCMD_F005_MISSING_MANDATORY_PARAM, "Missing mandatory parameter --Complement");
> }
> // regex expression for system_secret to be checked (Max 4Bytes, hexadecimal number in lowe case letters and no 0x format)
> regex regexp("^[0-9a-f]{1,8}$");
>
> // regex_search that searches pattern regexp in the string mystr
> std::string s = iter->second.c_str();
> if (false == std::regex_search(s, regexp))
> {
> // Only fatal. Statement is not initialized yet.
> Logger::fatal(Errors::RCMD_F006_INVALID_VALUE, "Invalid --Complement=hexvalue value");
> }
> else
> {
> // get hexadecimal value
> (void)sscanf(s.c_str(), "%X", &(m_cmdParameters.complementValue));
> }
>
> }
> With kind regards
> Elena Quesada Gonzalez
Do you have a complete minimal-ish test case that can be compiled and show the same thing happening? Even just a dummy main() to call the above the way you expect it to be called?
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [musl] SIGSEV error when using REGEX with musl library
2021-11-26 11:46 ` Quesada Gonzalez, Elena
@ 2021-11-26 16:32 ` Alex Xu
0 siblings, 0 replies; 4+ messages in thread
From: Alex Xu @ 2021-11-26 16:32 UTC (permalink / raw)
To: Quesada Gonzalez, Elena; +Cc: musl
Excerpts from Quesada Gonzalez, Elena's message of November 26, 2021 6:46 am:
> Hi,
>
> A simple main with the following code, should replicate the error.
>
> #include <regex>
> void main()
> {
>
> std::regex regexp("^[a-z0-9]{1,8}$");
> std::string s = ("0xAz10145274");
> if (false == std::regex_search(s, regexp))
> {
> // Only fatal. Statement is not initialized yet.
> printf("Invalid regex [%s]\n", __FUNCTION__);
> exit(1);
> }
> else {
> printf("Regex ok [%s]\n", __FUNCTION__);
> }
> }
>
> Thanks for your time
This program does not compile.
test.cpp:2:1: error: '::main' must return 'int'
2 | void main()
| ^~~~
After adjusting it to return int, it printed "Invalid regex [main]"
under both glibc and musl. After removing the anchors, it printed "Regex
ok [main]" under both glibc and musl.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-26 16:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 14:53 [musl] SIGSEV error when using REGEX with musl library Quesada Gonzalez, Elena
2021-11-25 15:52 ` Rich Felker
2021-11-26 11:46 ` Quesada Gonzalez, Elena
2021-11-26 16:32 ` Alex Xu
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).