Bend
Bend copied to clipboard
HVM output reader thread not ending after HVM returns
Reproducing the behavior
def main():
y = [1, 2, 3, 4, 5]
bend idx = 0:
when idx < 10:
sum = idx + fork(idx + 1)
else:
sum = 0
return sum
bend run returns 45
bend run-c and bend run-cu commands are stuck until termination
System Settings
- HVM + Bend: 5 minutes ago
- OS: Linux (Ubuntu 20.04) and other PC with WSL2
Additional context
No response
Hi! I couldn't reproduce the behavior from your bug report, could you give us some more information about which versions of hvm and bend you're using?
bend --version
hvm --version
Your GPU might not support running on CUDA since the current implementation has a few limitations (e.g. the GPU must have an L1 cache >= 128kb), but the C implementation should still run fine. Could you also tell us your CPU and GPU models?
Thanks!
@edusporto
Versions: bend-lang 0.2.22 hvm 2.0.17
Laptop with WSL2: CPU: AMD Ryzen 7 5800U with Radeon Graphics GPU: RTX 3050ti mobile
Backtrace from gen-c (maybe helpful):
RUST_BACKTRACE=full bend gen-c --warn=all main.bend
thread 'main' panicked at /home/ya/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hvm-2.0.17/src/main.rs:107:62:
ParseIntError { kind: InvalidDigit }
stack backtrace:
0: 0x5647c91ac095 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hed2c5e0a0ce6836c
1: 0x5647c91d050b - core::fmt::write::h846d656f7222a8c0
2: 0x5647c91a9a5f - std::io::Write::write_fmt::h67d939b7212f6891
3: 0x5647c91abe6e - std::sys_common::backtrace::print::h7a02369029f2cb19
4: 0x5647c91ad209 - std::panicking::default_hook::{{closure}}::he817c31d2eff8a0b
5: 0x5647c91acfaa - std::panicking::default_hook::h9dce7ab19378e0f9
6: 0x5647c91ad6c3 - std::panicking::rust_panic_with_hook::h114664f4a33b113f
7: 0x5647c91ad5a4 - std::panicking::begin_panic_handler::{{closure}}::hf849b4d9cc6b4bf3
8: 0x5647c91ac559 - std::sys_common::backtrace::__rust_end_short_backtrace::h69200ad086ea1fb0
9: 0x5647c91ad2d7 - rust_begin_unwind
10: 0x5647c91ce5d3 - core::panicking::panic_fmt::h8c3b34a341b30494
11: 0x5647c9115071 - core::panicking::panic_display::h2f3d74cff2d58c6e
12: 0x5647c9119b1d - hvm::main::{{closure}}::panic_cold_display::h91526b5a26f24d07
13: 0x5647c911901b - hvm::main::hd27cfc9a0437a56d
14: 0x5647c911ca63 - std::sys_common::backtrace::__rust_begin_short_backtrace::h37afc4cb0bea5705
15: 0x5647c911ca79 - std::rt::lang_start::{{closure}}::hcaa99320bb0fad10
16: 0x5647c91a542d - std::rt::lang_start_internal::h387be56a316c2f99
17: 0x5647c9119b55 - main
18: 0x7efe7e349fce - __libc_start_call_main
19: 0x7efe7e34a089 - __libc_start_main_impl
20: 0x5647c91139f5 - _start
21: 0x0 - <unknown>
exit status: 101
Oh, I found a reproducible example, sorry for misinformation in the original question:
This code stuck:
def main():
y = [1, 2, 3, 4, 5]
bend idx = 0:
when idx < 10:
sum = idx + fork(idx + 1)
else:
sum = 0
return sum
This not:
def main():
bend idx = 0:
when idx < 10:
sum = idx + fork(idx + 1)
else:
sum = 0
return sum
Looks like the thread that reads the HVM output is never ending with this program for some reason.
This code is looping in the expand_generated transformation
expand_generated expected generated functions to be never be recursive on other generated functions, which is no longer the case since we introduced bend and fold
Fixed by #539