Potential Bug - Processing compiler becoming unresponsive with negative text size

Hi,

I’m not sure if this a simple coding issue, or a bug, but I’ve recently when experimenting with textSize();, my Processing IDE froze, was unable to start any new program, and couldn’t even quit properly on my Macbook.

When I’ve run the program, an Exception was thrown: java.util.EmptyStackExceptionException in thread "Thread-1Exception in thread ".

Here is the code that caused the exception :

float size = 500;

void setup() {
  size(600,600);
  textSize(size);
  while (true) {
    textSize(size);
    size--;
    println(size);
  }
}

I’m not sure if it’s just me, and it would be nice to see if other users are experiencing this before I make a bug report on GitHub.

Thanks!

What is the while loop meant to do?! You’ve created an infinite loop which is taking up most of the CPU time on your machine. In general, never use while (true)

I’m just using while (true) as an example, in my real code, the loop will run around 100 times and still causes me to experience the same error.

float size = 10;

void setup() {
  size(600,600);
  textSize(size);
  int i = 0;
  while (i < 1000) {
    textSize(size);
    size--;
    println(size);
    i++;
  }
}

Also is sufficient.

OK, the loop still doesn’t make much sense. But why do you expect to be able to set a negative text size? What would that mean?

i got this:

-1.0
textSize(0.0) ignored: the text size must be larger than zero
-2.0
textSize(-1.0) ignored: the text size must be larger than zero

i don’t know what you want to achieve with a negative textSize, probably something like a 180° rotation i guess, but who knows. i tested your code in a windows computer

I don’t want to achieve anything with a negative text size, but the Processing compiler should still be able to handle it. I’m not using the above code for anything, it’s just the shortest way I could find to create the error.

My Processing freezes on that code, so it must just be my laptop.

Thanks!

1 Like

Thanks - looks like it’s not related to text size at all. :expressionless:

Do you know why the error pops up or what it means?

Yes, that’s what’s confusing everyone! :smile:

It seems that alternating output to System.out and System.err breaks PDE. Interesting!

Following sketch also replicates for me

for (int i=0; i < 1000000; i++) {
    System.err.println("ERROR");
    println("out");
}

That sounds terrible. Thanks for debugging rather than running away screaming.

You are right that almost anything with that behavior should be considered a bug – a Processing user should, ideally, not be able to take down their operating system by making a simple syntax error or logical error – for example passing textSize(mouseX -10) can make sense to someone who isn’t thinking specifically about the textSize(-1) case.

That said, glad that textSize wasn’t the issue.

Re:error spam locking up the sketch. Processing used to have severe problems with repeated println locking up the console – I believe this was mitigated with throttling, but your problem might be related. Did you open an issue?

1 Like

Opened an issue just now, waiting for an reply:

Thanks everyone for your help!

3 Likes