Closed edmizac closed 1 year ago
Thank you for your detailed steps to reproduce, @edmizac
I ran your model on my own machine however and did not face any issues, even with the slider set all the way to 200.
Can you share some more information about your machine? And can you also paste the error message (if any?) that you encounter?
For your reference, my machine is an intel macbook running macOS 13.3.1 and R version 4.3.1 (2023-06-16)
.
Thank you James for the fast response.
That is weird. I could reproduce the error in other two machines (three machines in total, all of them with Windows). My co-advisor was able to run it on Linux, though.
Actually, it only freezes. No error is thrown.
NetLogo 6.2.2 Windows 10 Home
Device name DESKTOP-R12V3D6 Processor Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz 1.99 GHz Installed RAM 16,0 GB (15,9 GB usable) Device ID 9E9736B3-A40B-43F1-A68E-CAD8A03966D1 Product ID 00326-10000-00000-AA961 System type 64-bit operating system, x64-based processor
> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8 LC_CTYPE=Portuguese_Brazil.utf8
[3] LC_MONETARY=Portuguese_Brazil.utf8 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1
NetLogo 6.3 Windows 10 Pro
DESKTOP-9PSSDHR 12th Gen Intel(R) Core(TM) i9-12900KF 3.20 GHz RAM 64,0 GB (63,8 GB) Devide ID 3BE65676-C7BC-4A81-B074-4DBC649C2562 Product ID 00331-10000-00001-AA655 System type 64 bits (x64)
> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8
[2] LC_CTYPE=Portuguese_Brazil.utf8
[3] LC_MONETARY=Portuguese_Brazil.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.utf8
time zone: America/Sao_Paulo
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
loaded via a namespace (and not attached):
[1] digest_0.6.31 progressr_0.13.0 utf8_1.2.3
[4] R6_2.5.1 tidyselect_1.2.0 magrittr_2.0.3
[7] glue_1.6.2 stringr_1.5.0 tictoc_1.2
[10] tibble_3.2.1 parallel_4.3.1 pkgconfig_2.0.3
[13] dplyr_1.1.2 generics_0.1.3 lifecycle_1.0.3
[16] cli_3.6.1 fansi_1.0.4 vctrs_0.6.3
[19] compiler_4.3.1 rstudioapi_0.14 tools_4.3.1
[22] pillar_1.9.0 rlang_1.1.1 stringi_1.7.12
NetLogo 6.3 Windows 10 Home
DESKTOP-71SL58S Processor Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz 3.40 GHz RAM 32,0 GB ID 6A58377A-C9CD-47B9-B046-B51368B95965 Product ID 00326-10000-00000-AA483 System 64 bits (x64)
> sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8 LC_CTYPE=Portuguese_Brazil.utf8
[3] LC_MONETARY=Portuguese_Brazil.utf8 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.utf8
time zone: America/Sao_Paulo
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.3.0
@edmizac Thanks for your detailed report, sample model, and the info from all the affected systems. I also could not reproduce when running on Linux, but I got ahold of a Windows 11 VM. The good news is the issue did occur there so I have a system I can work on. I'll try to track down a root cause and get it fixed; I'll post an update here once I have more info.
Okay, so it took me longer than I expected to get a fix, but I've published version 2.0.2 of the Simple R Extension to the extensions manager. Please test it out if you get a chance and let me know if it works for you.
The technical bits: I found the BufferedReader
that the core NetLogo Language Library was using was hanging on Windows when the given sample code was ran. I traced everything I could think of but could not find a cause. I decided to try making a simple custom line reader to drop in to maybe resolve the issue, or at least provide more debug information. That simple reader worked to resolve the problem. So I published the change and the Simple R extension as well. I'd love to know what the root cause was, but am happy to have something that might work.
Thanks, Jeremy. However, the issue continues...
I have updated simpleR in all machines I have access to, but I still get the same error (frozen screen). The only new thing is this error when I try to end NetLogo through the Windows Manager:
Is there a possibility for you to test it on a W10 machine?
Thank you and sorry for the late response.
@edmizac Thanks for letting me know. I checked the package and there was an issue with it (it contained the old interop library as well as the new one), but in testing the fixed version I found another issue. I'm working on that now and will update here once it's fixed.
@edmizac I have isolated a root cause of the issue, but I haven't got a fix just yet. The core issue is with the way the Simple R Extension redirects R's output back to the NetLogo Command Center; it's causing a deadlock in some scenarios (but not all).
Knowing the cause does provide a workaround: avoiding the use of print()
(and similar) statements in R code will avoid the deadlock. The easiest way to do that is to push the data back to NetLogo to display it, as in show sr:runresult "df1"
instead of sr:run "print(df1)"
. If there is a lot of data to be displayed and pushing it all back to NetLogo isn't desirable, another alternative is to write it out to a text file.
To be clear, this is definitely a bug and I'll be working on getting use of those R output commands working properly. I just want to get you the workarounds if it allows you to move forward with your work. Let me know if you have questions on it, or if you see hangs occur when not using any R output commands.
Thanks for your endeavor @LaCuneta
I should say I still get the same freezing even after running show sr:runresult "df1"
though.
I will do my best to circumvent all the debugging process without printing more than 110 lines.
Best,
@edmizac Okay, I have a new version of the Simple R Extension, 2.0.3, posted to the extensions library. I found a bug with the way NetLogo installs extensions that causes an issue; basically it can leave older versions of dependencies behind went updating an extensions. To workaround, you'll need to uninstall the Simple R extension and then re-install it instead of just updating it. You'll need to open NetLogo fresh without starting a model that uses the Simple R extension to make sure it can be removed. Let me know if you have any issues with the remove and re-install.
The new Simple R version should allow for use of any console output from R code, and should resolve any other issues you were still seeing. Please do let me know if that is not the case.
The root cause was that the console stdout
for the R process was becoming full before we had a chance to read it out, which caused the process to hang. The solution was to setup simple threads to read the stdout
async as soon as possible and keep it empty.
Thanks for the troubleshooting, Jeremy!
I am now printing more than 110 lines.
About installing/reinstalling: At first I got an unknown error from NetLogo 6.3.0 after trying to uninstall SimpleR. I reopened NetLogo (clean) and uninstalled sucessfully on the second try. So I guess no problems with it, also...
Thanks again!
Dear SR developers,
Following the guidance on an issue I have opened about NetLogo R extension, I have started adapting my code to the SR extension. However, my model was freezing as soon as I would use
set-data-frame
Thus, I developed another (but simpler) program that reproduces my original model steps and schedule. The same bug was happening after lists of more than 111 entries/steps (controled by a slider) were being assigned to a dataframe with the
set-data-frame
function. It works up to 110, but it crashes after 111.You can find the model attached here or check the .txt code below.
Thank you.
PS: In my original model with the R extension I was using
r:putdataframe
, which managed lists pretty ok. I have also tried other functions likesr:set-agent-data-frame
of SimpleR but I get the same freezing problem.