# Error: Multiple infinite loops detected. Stopping execution. at undefined:2:33088 \_ how do I resolve this?

**URL:** <https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974>\
**Category:** Coding Questions\
**Created:** [July 8, 2026, 1:03pm UTC](https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974 "2026-07-08T13:03:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![willdknyc](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@willdknyc](https://discourse.processing.org/u/willdknyc)\
**Post date:** [July 8, 2026, 1:03pm UTC](https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974/1 "2026-07-08T13:03:19Z")

</div>

\<!let img;  
let cnv;  
function preload() {  
img = loadImage(‘assets/IMG\_0299\_2.jpg’);  
}  
//only run once  
function setup() {  
cnv = createCanvas(img.width, img.height);  
let newCanvasX = (windowWidth - img.width)/2;  
let newCanvasY = (windowHeight- img.height)/2;  
cnv.position(newCanvasX, newCanvasY);  
//access the pixel information of the image  
for(let col = 0; col\< img.width; col+=2){  
for (let row =0; row\<img.height;row+=2) {  
let xPos =col;  
let yPos =row;  
let c = img.get(xPos,yPos);  
push();  
translate(xPos, yPos);  
rotate(radians(random(360)))  
noFill();  
stroke(color(c))  
strokeWeight(random(2));  
point(xPos, yPos);  
strokeWeight(random(4));  
//curve(x1, y1, x2, y2, x3, y3, x4, y4 )  
curve(xPos, yPos, sin(xPos) \* random(60), cos(xPos) \* sin(xPos) \* random (40), random(10), random(10), cos(yPos) \* sin(yPos) \* random(100), cos(xPos) \* sin(xPos) \* 50)  
pop();

function keyPressed(){  
if (key === ‘s’){  
saveCanvas(“portrait.jpg”);  
}  
}  
}  
}  
}–

---

<div class="post-metadata">

**Author:** ![davepagurek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/davepagurek/32/17535_2.png) [@davepagurek](https://discourse.processing.org/u/davepagurek)\
**Post date:** [July 8, 2026, 2:28pm UTC](https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974/2 "2026-07-08T14:28:46Z")

</div>

If you go to the settings for your sketch and scroll to the bottom, you can turn loop protection off.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/1/4152f596437169687a02f4b33040dc85af9607be.png)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 8, 2026, 4:14pm UTC](https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974/3 "2026-07-08T16:14:05Z")

</div>

Hello @willdknyc,

Welcome to the forum.

Please read:  
_[Welcome to the Processing Foundation Discourse](https://discourse.processing.org/t/welcome-to-the-processing-foundation-discourse/8)_

There is a useful guide in there: [Guidelines - Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147/)

You should also share the version of _p5.js_ that you are using; I got different errors with the latest p5.js 2.x version.

Your code is not runnable as is and I had to simplify it to run _without an image._

Once simplified the canvas was blank (all one color) and this worked to get different colors (replaces image for testing):

```auto
      //let c = get(xPos, yPos);
      let c = color(random(255), random(255), random(255));

```

I had to correct an error with `keyPressed()` first (commented it out entirely for starters) and then I saw this with version _p5.js 1.11.13 (Default)_:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/9/b9f1bf48feddbe853d719ffa4b2d0522fe46b916.png)

And code works with the Loop Protection **Off** :

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/4/643082ebfe95706b87acad997488035eb7441d97.png)

`:)`

---

<div class="post-metadata">

**Author:** ![willdknyc](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@willdknyc](https://discourse.processing.org/u/willdknyc)\
**Post date:** [July 8, 2026, 5:37pm UTC](https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974/4 "2026-07-08T17:37:14Z")

</div>

Thanks for the solution.

---

<div class="post-metadata">

**Author:** ![ProcessingOrg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/processingorg/32/18341_2.png) [@ProcessingOrg](https://discourse.processing.org/u/ProcessingOrg)\
**Post date:** [July 9, 2026, 10:31am UTC](https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974/5 "2026-07-09T10:31:10Z")

</div>

A post was split to a new topic: [“You cannot upload any more files” in p5.js web editor](https://discourse.processing.org/t/you-cannot-upload-any-more-files-in-p5-js-web-editor/48976)

---

<div class="post-metadata">

**Author:** ![ProcessingOrg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/processingorg/32/18341_2.png) [@ProcessingOrg](https://discourse.processing.org/u/ProcessingOrg)\
**Post date:** [July 9, 2026, 10:31am UTC](https://discourse.processing.org/t/error-multiple-infinite-loops-detected-stopping-execution-at-undefined33088-how-do-i-resolve-this/48974/6 "2026-07-09T10:31:50Z")

</div>


