ra4king / CircuitSim

Basic Circuit Simulator
https://ra4king.github.io/CircuitSim
BSD 3-Clause "New" or "Revised" License
76 stars 27 forks source link

java.lang.ArrayIndexOutOfBoundException: Index 2239 out of bounds for length 2048 #96

Open NathanDuggal opened 1 year ago

NathanDuggal commented 1 year ago

MicrosoftTeams-image

ausbin commented 11 months ago

For the record, this is happening inside of the CircuitSim autograder library. I don't think we have observed this when opening CircuitSim itself, so this could be an unexpected/unusual situation created by the grader library

jiyaski commented 11 months ago

I'm a CS 2110 student and I encountered this issue as well. A TA told me to put my system configuration here, so:

OS: Windows 11 Home, 64-bit, v22H2, build 22621.2283 Processor: Intel i7-12700H RAM: 32GB java version "17.0.8" 2023-07-18 LTS Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211) Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)

I ran the file using java -jar project1-tester-1.0.jar in the directory with all the .sim files used for the project. I got this error a few times, but later I stopped encountering it even though I didn't do anything aside from working on the .sim files. I am unable to reproduce the error now.

ausbin commented 11 months ago

What adds to the spicy nondeterminism is that @jiyaski (above) got a slightly different error (notice the bounds are different):

image

I am trying to see if this is caused by "editing the GUI in a non-JavaFX thread". (Edit: no shot. This is running directly in a Platform.runLater())

ausbin commented 11 months ago

Possibly related issue a student on Windows is seeing with CircuitSim itself (I don't know about the autograder):

image

Some info on their system:

OS: Microsoft Windows 11 Home Version 10.0.22621 Build 22621

Processor: Processor 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz, 2304 Mhz, 8 Core(s), 16 Logical Processor(s)

Bios: BIOS Version/Date Dell Inc. 1.22.0, 7/13/2023

System Type: x64-based PC

Running CircuitSim with software rendering seemed to get it to work:

java -Dprism.order=sw -jar CS2110-CircuitSim.jar
ausbin commented 11 months ago

Another instance with CircuitSim itself:

"java.lang.NullPointerException: Cannot invoke "com.sun.prism.d3d.D3DTextureData.getContext()" because the return value of "com.sun.prism.d3d.D3DTextureResource.getResource()" is null
        at com.sun.prism.d3d.D3DTexture.getContext(D3DTexture.java:85)
        at com.sun.prism.d3d.D3DTexture.update(D3DTexture.java:210)
        at com.sun.prism.d3d.D3DTexture.update(D3DTexture.java:154)
        at com.sun.prism.impl.BaseContext.flushMask(BaseContext.java:115)
        at com.sun.prism.impl.BaseContext.drawQuads(BaseContext.java:124)
        at com.sun.prism.impl.VertexBuffer.flush(VertexBuffer.java:98)
        at com.sun.prism.impl.BaseContext.flushVertexBuffer(BaseContext.java:107)
        at com.sun.prism.impl.ps.BaseShaderContext.setRenderTarget(BaseShaderContext.java:789)
        at com.sun.prism.impl.BaseContext.setRenderTarget(BaseContext.java:149)
        at com.sun.prism.impl.BaseGraphics.<init>(BaseGraphics.java:107)
        at com.sun.prism.impl.ps.BaseShaderGraphics.<init>(BaseShaderGraphics.java:86)
        at com.sun.prism.d3d.D3DGraphics.<init>(D3DGraphics.java:40)
        at com.sun.prism.d3d.D3DGraphics.create(D3DGraphics.java:63)
        at com.sun.prism.d3d.D3DSwapChain.createGraphics(D3DSwapChain.java:148)
        at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:88)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
        at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:358)
        at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:126)
        at java.base/java.lang.Thread.run(Thread.java:1623)"

System info:

System Model ROG Zephyrus M16 GU603ZM_GU603ZM

OS Name Microsoft Windows 11 Home Version 10.0.22621 Build 22621 Processor 12th Gen Intel(R) Core(TM) i7-12700H, 2300 Mhz, 14 Core(s), 20 Logical Processor(s) Total Physical Memory 39.7 GB Available Virtual Memory 25.0 GB Page File Space 1.00 GB Built-in Intel(R) Iris(R) Xe Graphics, Drivers: 31.0.101.3962 DX12 Dedicated 3060 Laptop 6GB, Drivers: 30.0.15.1278 DX 12

Run on external monitor via DisplayPort hub.

Yanderuri commented 11 months ago

I've also ran into this problem on vanilla CircuitSim (not the 2110 fork). Both the Jar file and installed CircuitSim freezes up after loading up our project file for 2200.

System info

OS Name Microsoft Windows 11 Pro
Version 10.0.22621 Build 22621
System Type x64-based PC
Processor   AMD Ryzen 5 3600 6-Core Processor, 3600 Mhz, 6 Core(s), 12 Logical Processor(s)
BIOS Version/Date   American Megatrends Inc. 6203, 7/27/2023
Installed Physical Memory (RAM) 32.0 GB
Total Physical Memory   31.9 GB
Available Physical Memory   20.4 GB
Total Virtual Memory    33.9 GB
Available Virtual Memory    16.8 GB
Adapter Type    NVIDIA GeForce RTX 3070, NVIDIA compatible
Driver Version  31.0.15.3667

Azul Zulu JDK 17.44.15 (17.0.8) 64-bit
Also tested with vanilla Java 17
Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211)

@ausbin command with software rendering fixed it for now. Also recompiled master branch with jfx20 and the jar seems to run normal now. Loading the same file doesn't freeze up (thanks again @ausbin)

ra4king commented 11 months ago

From looking at the Canvas, GraphicsContext, and GrowableDataBuffer source, it seems this error can only happen from a race condition. It looks like CircuitSim.updateCanvasSize isn't wrapped in a runFxSync block so I just made that change in commit 3256d3b91d8a7d0d692e42453c5fab71ac5818ff. I created v1.9.2b, let me know if this fixes the issue: https://www.roiatalla.com/public/CircuitSim/

AchyutanNarayanan commented 11 months ago

I attempted to load CS2200 project 2, but immediately after loading it, CircuitSim (1.9.2b, but a similar issue happened with 1.9.1) would freeze with the issue "Unrecognized PGCanvas Token". I have attached the image showing the error. I use a Mac M1 2020.

Screenshot 2023-09-21 at 12 54 35

The files that cause the error are here: https://drive.google.com/drive/folders/1iiQZXFuXqtzo6IKHPaKczABrjDiRnrPJ?usp=sharing