Open zhopan77 opened 5 years ago
The script is long, but I don't know how to get a minimal example that can re-produce the same problem.
Keep removing code until the problem stops happening?
Also can you reproduce this completely outside of Juno?
Thanks @KristofferC for quick response.
I confirmed that the same problem also happens when I have no Juno involvement - just running from a simple Windows console I have exactly the same symptom.
I will try to reproduce the problem using a smaller script.
Just to update my progress. I narrowed down the problem between line 1185 and 1188. If I set break point at line 1185, I can break properly; line 1186 is empty line and line 1187 is a comment; but if I set break point at line 1188, somehow the debugger will continue until line 1358 which is a println() statement (but it's NOT the only println() statement between line 1187 and 1358).
In addition, adding break point for any line between 1188 and 1358 will result in breaking at 1358. But adding break point AFTER line 1358 results in breaking at the correct line.
I don't see anything special for the code between lines 1188 and 1358 though. :-(
Tried creating simpler script file with similar imports, functions, loops, comments, multi-line statements... Nothing can reproduce the problem.
Tried a simpler script that goes to 1,400+ lines long with many empty lines in between. Still cannot reproduce the problem when I set break point between line 1188 and 1358.
One hint though. In the original script, the first 1,188 lines contains 62,590 characters, while the first 1,358 lines contains 75,021 characters. Since these two numbers crosses 65,536 which is 2^16, not sure if this made any difference in terms of buffer allocation etc. :-)
It seems it's still related to the statement rather than the location.
I removed ~40 lines of code up front, but the break point problem still happens at around the same statements. Difference is I can break at line 1,148 (which was line 1,188) correctly now; I can even go to line 1,149, but the problem starts at line 1,151 now (58,882 characters), and any break point in between 1,151 and 1,318 now jumps to 1,318 (which is the same statement as line 1,358), including 71,144 characters.
However the statement where the problem starts is nothing special. Similar function calls happened several times earlier in the script.
Keep cutting down the code is tough as later code relies on things defined/calculated earlier...
I verified the cause is not number of characters.
I created a large script in the following format:
function main()
n = 2; NPRINT = 1;
n += 1; if n % NPRINT == 0 println("This is line $n"); end
n += 1; if n % NPRINT == 0 println("This is line $n"); end
n += 1; if n % NPRINT == 0 println("This is line $n"); end
...
end
main();
The "..." above means the same line is repeated for a total of about 1100 times. This will ensure the number of characters is well above 65,536.
I then tried setting break point from line 800 to line 1100 randomly and the debugger always breaks at the correct line.
So why the original source code has such a problem is still a mystery. :-(
OK I guess the problem may be related to this closed issue #219 for JuliaInterpreter.
I didn't notice that issue #219 had been closed, so in my original main script above I had a global variable
isPlot = false;
if isPlot
using PyPlot;
end
and I wrapped all PyPlot uses within blocks like
if isPlot
# do PyPlot operations ...
end
Only when I want to show the plot I'll set isPlot = true; otherwise I leave it to be false, including when I use the Debugger. Note that I also used a self-made module which contains "using PyCall" and "using PyPlot", but in the main script I never called any function in that self-made module that will actually use anything from PyCall or PyPlot.
Now the strange thing is, once I REMOVED all lines related to PyPlot from the main script, I cannot reproduce the problem above anymore. (The "using PyCall" and "using PyPlot" statements are still there in the self-made module used.)
I did try a simple script with only a few statements, and I deliberately sprinkled PyPlot related blocks in several places. However, I cannot reproduce the problem above. So I only know the problem seems to be related to PyPlot, but I still cannot find a simple and deterministic way to re-create it.
Using @bp is an acceptable workaround in the rare case this problem shows up, so I'll leave this issue open here but won't spend more time on it.
I have a script about 1,600 lines long which uses a bunch of installed packages as well as self-created modules.
After I set a break point on a line (using either Juno's GUI or the "bp add line" command from the REPL after using the Debugger package) then continue, the actual break happens about 100 lines after the line where I placed the break point.
I tried enabling or disabling the Complied Mode (either through Juno GUI or the "C" command in REPL), and I got the same problem.
However, if I add the break point by adding a line "@bp" inside my script, the break happens at the right location, regardless if I use Juno.@enter or @enter.
The script is long, but I don't know how to get a minimal example that can re-produce the same problem.
Here's my Julia client's Debug Info: