Bug 498423 - stop does not cancel the execution of the script
Summary: stop does not cancel the execution of the script
Status: RESOLVED NOT A BUG
Alias: None
Product: rkward
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR major
Target Milestone: ---
Assignee: RKWard Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-09 11:18 UTC by Jan
Modified: 2025-05-12 07:50 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan 2025-01-09 11:18:30 UTC
Using RKWard 0.8.1 (rkward-master-1453-linux-gcc-x86_64.AppImage) at Lubuntu 24.04.1

SUMMARY

Neither stop() command in script nor "Interrupt all commands" nor "Interrupt running command" on GUI stops further execution of the script.

STEPS TO REPRODUCE

1. Open RKWard.
2. New Script File.

print("start")
stop()
Sys.sleep(Inf)
print("end")

3. Run all.

4. Press "Interrupt all commands" or "Interrupt running command".

OBSERVED RESULT

> print("start")
[1] "start"
+ stop()
Error: 
+ Sys.sleep(Inf)

+ print("end")
[1] "end"
> 

EXPECTED RESULT

Script should stop at stop(). But it continues. The command Sys.sleep(Inf) makes it wait. If you press the button "Interrupt all commands" or "Interrupt running command", the execution of the script should be terminated. But the script is executed to the end.

ADDITIONAL INFORMATION

- using R-version from cran
- command works from R terminal without error
- R_X11.so and cairo.so are where you expect them to be

sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0

locale:
[1] LC_CTYPE=de_DE.UTF-8          LC_NUMERIC=C                  LC_TIME=de_DE.UTF-8           LC_COLLATE=de_DE.UTF-8        LC_MONETARY=de_DE.UTF-8      
[6] LC_MESSAGES=de_DE.UTF-8       LC_PAPER=de_DE.UTF-8          LC_NAME=de_DE.UTF-8           LC_ADDRESS=de_DE.UTF-8        LC_TELEPHONE=de_DE.UTF-8     
[11] LC_MEASUREMENT=de_DE.UTF-8    LC_IDENTIFICATION=de_DE.UTF-8

time zone: Europe/Berlin
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] XML_3.99-0.18 RODBC_1.3-26  rkward_0.8.1 

loaded via a namespace (and not attached):
[1] compiler_4.4.2 tools_4.4.2    grid_4.4.2     lattice_0.22-6
Comment 1 Thomas Friedrichsmeier 2025-05-04 15:07:37 UTC
Sorry for the late reply. I cannot reproduce with a current build and the development version of R.

This really seems to be a combination of two issues:
1) Code continues to run after stop(). Could you check options("error")? Currently RKWard needs options(error=.rk.do.error) to find out, if an error occurred inside a user command. This is set on startup, but maybe you're overriding it, somehow? I agree, I should really look into a different solution, here, though.

2) Non-interuptable sleep. Do you see this always? Sometimes? I cannot reproduce this, although there have in fact been bugs that could have caused command interruption to fail on occasion (but you should have seen that rarely, at most). Either way, could you try again with a recent build?
Comment 2 Thomas Friedrichsmeier 2025-05-04 20:34:00 UTC
Note to myself:
> Currently RKWard needs options(error=.rk.do.error) to find out, if an error occurred inside a user command.

We might be able to detect errors using R_ResetConsole, instead, which get called (only?) in case of errors. It is available (also) on Windows sine R 4.2.0.
Comment 3 Jan 2025-05-12 07:50:25 UTC
Thanks for taking the time to investigate the bug.

It was indeed options(error=.rk.do.error) that was overwritten. I have set options(error=NULL). I actually can't remember why I do that. This worked in earlier versions of RKWard, but no longer in the versions that are available as AppImage.
Now it works again, including stopping the infinite sleep.