YAML Emitter using YAML::DoubleQuoted when emitted in a destructor of a staticly created struct/class
@alex-thiessen-for-siemens ya está trabajando en esto.
Desde el 20/9/2026.
- #1500 de @alex-thiessen-for-siemens — abierto
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 6.1k
- Forks
- 2.2k
- Merge medio
- 22 h 2 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de jbeder/yaml-cpp
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Explicit `!!null` tag with empty content loads as a Scalar node instead of NullPosiblemente ocupada @ppc64el la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
-
Dificultad 3/5 Medio día Aptitud para principiantes 55/100
Todos los issues de jbeder/yaml-cpp
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
arvidn/libtorrent#9149 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Niko1221/Strata#5560 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
NVIDIA windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[辞書] C/C++のプリプロセッサ指令名を英字のままにするAbierto要トリアージ 辞書
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
yksr-melt/Meltype#1625 · 1 reacción ·
Los mantenedores suelen responder en 1 día