Bug 421958 - RKWard and R 4.0.0 breaks during for-loop
Summary: RKWard and R 4.0.0 breaks during for-loop
Status: RESOLVED FIXED
Alias: None
Product: rkward
Classification: Applications
Component: R Console (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR grave
Target Milestone: ---
Assignee: RKWard Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-23 09:31 UTC by flyos
Modified: 2020-05-26 07:21 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description flyos 2020-05-23 09:31:50 UTC
SUMMARY
Since updating to R 4.0.0, running a for loop for a second time results in an error, preventing the code to run successfully. This only happens in RKWard, not in command line R.


STEPS TO REPRODUCE
1. Open RKWard (with R 4.0.0) and the R console panel.
2. Input this minimal working example: "for (i in 1:100) { print(i) }", everything seems to work.
3. Input the line once again: "for (i in 1:100) { print(i) }", this times, it results in an error.

EXPECTED RESULT
The second for-loop should yield numbers from 1 to 100, as it does for the first time.

OBSERVED RESULT
Instead, it yields 100 NULL values and the following error, displayed twice:
Error in ls(globalenv(), all.names = TRUE) : 
  Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'NULL'


SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20200519
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.70.0
Qt Version: 5.14.1
Kernel Version: 5.6.12-1-default
OS Type: 64-bit
Processors: 4 × Intel® Core™ i3-2120 CPU @ 3.30GHz
Memory: 7,7 Gio

ADDITIONAL INFORMATION
RKWard 0.7.1
R 4.0.0
Comment 1 Thomas Friedrichsmeier 2020-05-23 11:58:22 UTC
Confirmed. Thanks a lot for reporting!

This seem to be at least partially due to the following:
https://stat.ethz.ch/pipermail/r-devel/2020-May/079561.html

I'm currently investigating options to fix this, but it looks rather tricky, indeed...
Comment 2 flyos 2020-05-23 12:05:07 UTC
I looked for the error over the Internet, it doesn't seem to be highly specific/informative, indeed. I hope this message of yours picks some interests (by someone who knows an easy fix?).
Comment 3 Thomas Friedrichsmeier 2020-05-23 12:16:37 UTC
Well, this definitely looks like a bug in R, although I am afraid active bindings are not a heavily used feature in R, and depending on how hard this is to fix, it may or may not get priority.

The short term workaround - I'll admit it is a lousy on - is to either put the whole for()-loop into a local() environment, or to remove the loop index after using it.

The fallback plan for RKWard is to avoid using active bindings (we happen to use them for detecting when a symbol has been changed). This has been on my TODO list for a long time, for performance reasons, but unfortunately it's not quite trivial to implement...
Comment 4 Thomas Friedrichsmeier 2020-05-24 08:26:22 UTC
Git commit f1e12da76b7ea4dbcb99c8a38ce9dbb5cb96e1a6 by Thomas Friedrichsmeier.
Committed on 24/05/2020 at 08:25.
Pushed by tfry into branch 'master'.

Workaround to avoid bug in R 4.0.0 when using for loop on top level context

M  +1    -0    ChangeLog
M  +5    -0    rkward/rbackend/rkrinterface.cpp

https://invent.kde.org/education/rkward/commit/f1e12da76b7ea4dbcb99c8a38ce9dbb5cb96e1a6
Comment 5 flyos 2020-05-26 07:21:26 UTC
I can confirm the new update to 0.7.1b fixes the bug (both for the MWE above and my original script). I'm taking the liberty to mark the bug as RESOLVED (although I'm aware the workaround isn't very satisfying and the actual bug being in R, I'd still rather mark this as FIXED rather than UPSTREAM).