[BUG] ETW Properties::to_vector doubles the result and reads past a string_view
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- cpp
- Área
- observability-sre
Línea de trabajo
Lea exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h alrededor del generic overload de la línea 84 y del string_view overload de la línea 94; después, inspeccione PropertyVariant::operator= alrededor de la línea 260. Verifique el ETW exporter con un span de string views, asegurándose de que el vector devuelto tenga la misma longitud y preserve el contenido de las views no terminadas en NUL; tenga en cuenta que actualmente ningún trabajo de CI compila ETW.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Properties::to_vector(span<string_view>) in exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h:94 has two defects on adjacent lines:
std::vector<std::string> static to_vector(const nostd::span<const nostd::string_view> &source)
{
std::vector<std::string> result(source.size());
for (const auto &item : source)
{
result.push_back(std::string(item.data()));
}
return result;
}
The result is twice the size it should be. std::vector<std::string> result(source.size()) value-initialises source.size() empty strings, and the loop then appends source.size() more. A span of three views comes back as six entries whose first three are empty.
std::string(item.data()) reads until a NUL. The function's own comment says the input is a span of "non-owning string views", and nostd::string_view::data() is not required to point at a NUL terminated buffer, so this can read past the view and copy whatever follows it.
The generic overload immediately above, at line 84, is correct and does neither:
template <typename T>
static std::vector<T> to_vector(const nostd::span<const T, nostd::dynamic_extent> &source)
{
return std::vector<T>(source.begin(), source.end());
}
so the string_view overload looks like a copy that diverged.
It is live code. PropertyVariant::operator= calls it at line 260 for AttributeType::kTypeSpanString, so any ETW span or log record carrying a string-array attribute goes through it.
Why this is a report rather than a pull request
No CI job builds the ETW exporter. WITH_ETW appears in no workflow and in no branch of ci/do_ci.sh; the only workflow that names ETW at all is cppcheck.yml, which analyses rather than compiles. A fix here cannot be verified by the pipeline, and the to_vector change is entangled with the sizing bug rather than being a one line correction, so I would rather not push a blind change into a Windows-only path.
The suggested shape, if a maintainer wants it:
std::vector<std::string> result;
result.reserve(source.size());
for (const auto &item : source)
{
result.push_back(static_cast<std::string>(item));
}
return result;
nostd::string_view has an explicit operator std::string() that copies by length.
I am happy to send that, but it would be more useful alongside a job that compiles the ETW exporter, since the sizing bug is the kind a single assertion would have caught. Found while sweeping the same string_view::data() shape for #4346, which fixes the four occurrences in components that CI does build.
- Lenguaje dominante
- C++
- Estrellas
- 1.4k
- Forks
- 660
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 47
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una 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 open-telemetry/opentelemetry-cpp
-
Baggage::ToHeader/FromHeader use form-style `+` for space, which other W3C Baggage implementations read as a literal plusPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug triage/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
open-telemetry/opentelemetry-cpp#4745 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[CMake] Strengthen pkg-config installation tests to detect missing metadata and dependenciesAbiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
open-telemetry/opentelemetry-cpp#4697 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
TracerContext construction might result in a terminateQuizá libre de nuevo @akshat-lakhera la tomó hace 25 días y no hay ningún pull request abierto. Abiertotriage/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
open-telemetry/opentelemetry-cpp#4684 · 2 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
[CI] Add Ubuntu 26.04 runners to the CI workflowQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertotriage/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
open-telemetry/opentelemetry-cpp#4596 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
[BUG] Resource::Create() throws bad_variant_access if process.executable.name isn't a stringPosiblemente ocupada @ryux1 la tomó hace 59 días. Abiertobug help wanted triage/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
open-telemetry/opentelemetry-cpp#4535 · 1 comentario · 2 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de open-telemetry/opentelemetry-cpp
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
mw00/project-maya#877 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
llvm/offload-test-suite#1703 ·
Los mantenedores suelen responder en 1 día
-
test(tools): test_invite_answer_wiring scans nothing in a checkout whose path contains tests/Abiertobacklog bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
EchoTools/nevr-runtime#2154 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
BGI-shenzhen/PopLDdecay#25 ·