hyperlight-dev / hyperlight-dev/hyperlight
When using the HYPERLIGHT_COMPONENT_MACRO_DEBUG flag with multiple calls the files are not loaded properly
- Lenguaje dominante
- Rust
- Estrellas
- 4.7k
- Forks
- 208
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 48
Descripción
this is the line that causes race condition, if you call host_bindgen macro multiple times in a file, with different .wasm files, then you will not get the correct generated code back, even though the macro actually generates the correct code.
This is happening because of the following reason
1. host_bindgen() ----------> macro called for the first time --> output gets saved to file.
2. host_bindgen() ----------> macro called for the n(th) time --> it may return the content of the file that was saved by previous run of the macro on some other .wasm file.
I have tested this multiple times on local pc.
This only happens when we have the `HYPERLIGHT_COMPONENT_MACRO_DEBUG` os env set, because it is writing to the file system. I think the rust std::fs::write() is either lazy or not synchronous.
This happens because all the macro runs are manipulating the same file on filesystem.
if we need to access the file, then we should do std::fs::read separately, instead of relying on the return value of this function.
_Originally posted by @vshailesh in https://github.com/hyperlight-dev/hyperlight/pull/1020#discussion_r2608220783_
Guía de contribución
Línea de trabajo
Locate the host_bindgen macro implementation and the HYPERLIGHT_COMPONENT_MACRO_DEBUG path, then reproduce the issue by invoking host_bindgen multiple times with different .wasm files. Done means each invocation returns or loads the generated content for its own input rather than content written by another invocation.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100