YAML Emitter using YAML::DoubleQuoted when emitted in a destructor of a staticly created struct/class
@alex-thiessen-for-siemens ci sta già lavorando.
Dal 20/9/2026.
- #1500 di @alex-thiessen-for-siemens — aperta
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with the issue’s example and inspect emitter.h, especially YAML::Emitter::Write(const std::string&) and its StringFormat::value regex check. Reproduce the output difference between the call in main() and the destructor, then trace why the regex match changes during static destruction. Done means both serializations emit the same unquoted YAML; the issue does not name a test file.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What steps will reproduce the problem?
-
Create a struct/class containing a destructor and a function to serialize an arbitrary type of data, with the destructor calling the serialization function.
-
Create a static instance of that class and call the serilization function at least once.
What is the expected output? What do you see instead?
The expected output would be to see the serialized data, as many times as requested, beeing exactly the same, however, the last time the yaml string is printed, all keys, as well as all strings, are wrapped in double quotes.
Example
struct EmitterTest
{
~EmitterTest()
{
Serialize();
}
void Serialize()
{
YAML::Emitter out;
out << YAML::BeginMap << YAML::Key << "Test";
out << YAML::BeginMap;
out << YAML::Key << "String1" << YAML::Value << "String1";
out << YAML::Key << "String2" << YAML::Value << "String2";
out << YAML::Key << "String3" << YAML::Value << "Foo";
out << YAML::EndMap;
out << YAML::EndMap;
std::cout << out.c_str() << std::endl;
}
}
static EmitterTest s_Test;
int main()
{
s_Test.Serialize();
}
Expected output:
Test:
String1: String1
String2: String2
String3: Foo
Test:
String1: String1
String2: String2
String3: Foo
Actual output:
Test:
String1: String1
String2: String2
String3: Foo
"Test":
"String1": "String1"
"String2": "String2"
"String3": "Foo"
yaml-cpp version: 0.8.0
Additional Information
Note that this only happens when Serialize() is called once before destruction. Digging into the problem makes the problem pretty obvious: In emitter.h the function YAML::Emitter::Write(const std::string&) queries the StringFormat::value, by trying to match the string with a regex. This regex match returns false in the serialization called in the destructor, otherwise it returns true.
- Lingua principale
- C++
- Stelle
- 6.1k
- Fork
- 2.2k
- Merge medio
- 22h 2m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di jbeder/yaml-cpp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 55/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
Tutte le issue di jbeder/yaml-cpp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cython/cython#8110 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ROCm/rocm-systems#14923 ·
I maintainer di solito rispondono entro 2 giorni
-
arrays asr pass bug ICE intrinsic medium priority
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Area: World-Readiness
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
microsoft/calculator#2522 ·
-
missing `catch.hpp`Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoft/inflatelib#34 · 1 commento ·