Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"exited with code -11" error #518

Open
cabakasap opened this issue Sep 28, 2024 · 13 comments
Open

"exited with code -11" error #518

cabakasap opened this issue Sep 28, 2024 · 13 comments

Comments

@cabakasap
Copy link

Hi,

I just noticed that Thonny sometimes runs the slide show but sometimes it gives the error 'process ended with exit code -11'.

I read somewhere that "the error message of code -11 typically indicates a "Segmentation Fault" (SIGSEGV). This is a specific kind of error caused by a program trying to read or write an incorrect location in memory, or when a program tries to write into a memory area that is read-only.

The "exited with code -11" part means that the script stopped because of the segmentation fault, which is represented by the signal number 11 in Unix-based systems. Segmentation faults are often caused by programming errors that involve the misuse of pointers, array bounds overruns, incorrect use of system calls, trying to use an uninitialized pointer, or a host of other issues."

I am running macOS Ventura 13.0. And my Thonny is 4.0.2.

Why do I encounter that error which runs from time to time? Is this a problem with the coding or a system memory error?
Thanks.
Çağrı Kasap

@hx2A
Copy link
Collaborator

hx2A commented Sep 28, 2024

Hi, @cabakasap ! Thank you for your question.

Yes, sometimes when py5 Sketch exits there are some odd exit codes. I've done my best to tackle most of them and have been fairly successful. There are still some residual problems though. Much of the issue seems to come from within Processing itself. When Processing (running through the Processing Development Environment, aka the PDE) exits a Sketch, it will call System.exit(), shutting down the Java Virtual Machine (JVM). This is a heavy-handed way of exiting but it is consistently successful.

The issue py5 faces is that it cannot call System.exit(). If that happened, you would not be able to run another Sketch without restarting the Python process. This limitation comes from JPype, the Python library that py5 depends on to connect to the JVM. Once you shutdown the JVM, you cannot restart it a second time.

Since py5 cannot call System.exit(), it must find a different way to shut down the Sketch and dispose of resources. This took a lot of time and effort to figure out. It isn't perfect. Hence, the occasional non-zero exit code.

This is something I do continue to think about, though, and if I come up with a better idea for how to handle it, I will certainly implement it. In the meantime, though, you can safely ignore the non-zero exit code.

@cabakasap
Copy link
Author

Hi there,
Jim thank you for your response. I am running a slideshow and sometimes Thonny gives the error 'process ended with exit code -11'' before it the show even starts, not at the end when I am exiting the show but at the beginning when I am starting it. It inhibits me from starting the slideshow even. Maybe on the fifth attempt or so I can successfully start it. Are you sure it has nothing to do with the code itself?

@hx2A
Copy link
Collaborator

hx2A commented Sep 29, 2024

sometimes Thonny gives the error 'process ended with exit code -11'' before it the show even starts

Wait, that shouldn't happen. What do you mean by a "slideshow"? Is this something you programmed with py5? Can we see the relevant parts of your code?

@villares
Copy link
Collaborator

Cheers @cabakasap! I think we exchanged some messages about a slideshow-like idea... was it something like this?
https://gist.github.com/villares/968c41e594db6b83172700dcf856a09b

@villares
Copy link
Collaborator

Please, @cabakasap, can you give us more information so we might be able to investigate this better for you and others on Macs?

  • Do other sketches have the same problem? Can you share some of your code that triggers this problem?
  • If you try a "module mode" sektch (using import py5 and with the thonny-py5mode plug-in turned off) is it the same?
  • Could you perhaps try Thonny 4.1.6, installing py5 to it, etc., to see if it makes a difference?

@cabakasap
Copy link
Author

Cheers @cabakasap! I think we exchanged some messages about a slideshow-like idea... was it something like this? https://gist.github.com/villares/968c41e594db6b83172700dcf856a09b

Hi @villares. Yes that is me.

  • Other sketches do not have the same problem. Another sketch states that 'process ended with code exit code 0' and it runs the first time I try.

Here is the starting part of my code:
time_per_image = 7000 # milliseconds
fade_time = 500 # actually fade in + fade out will be double this
last_image_time = 0
seed = 0

def setup():
full_screen ()

def draw():
global seed
global last_image_time
background(220, 110, 50)
random_seed(seed)
cols = 15
rows = 10
v_margin = 50
grid_height = height - v_margin * 2
grid_width = grid_height / rows * cols
h_margin = (width - grid_width) / 2
for _ in range(3):
grid(h_margin, v_margin, cols, rows, grid_width)

*When I try to turn-off the py5 mode, it does not run anything. I mean even the error code does not occur. Thonny editor window just remains as it is.

*I installed Thonny 4.1.6 version and it is still the same. Nothing changed. I still get the same error for the first 4 attempts and then in the fifth attempt, I can get it to work.

Regards.

@villares
Copy link
Collaborator

villares commented Oct 6, 2024

Thank you for the patience and testing. The most curious thing is that it fails 4 times and then works, very unusual!

  • Can you please check if not using fullscren(), using normal size(...) makes a difference?

  • *Note that for you to test with the plug-in turned off you would have to re-write everything in module mode (the import py5 style), so you would have to add py5. to all py5 functions (like py5.background(220, 110, 50)) and special variables (like py5.mouse_x, or py5.key, etc. ) and in the end add py5.run_sketch().

@cabakasap
Copy link
Author

@villares, I just checked the first thing you suggested. I just changed the fullscreen() to a normal size (1600, 1600) that I have just assigned and it worked. I did not get any errors and it worked properly each time I tried.

So the problems seems to be with the fullscreen() command.

Any suggestion as to why that happens then?
Çağrı

@villares
Copy link
Collaborator

villares commented Oct 6, 2024

Thank you @cabakasap, that's very very very useful information and @hx2A will have a starting point to investigate now.

But it could take some time before he can fix this, so, for the time being, you might need to try some workarounds like making the window a bit bigger than the screen and moving it up a bit to hide the title, maybe with window_move()

@hx2A
Copy link
Collaborator

hx2A commented Oct 7, 2024

Hi, @cabakasap ! Sorry for my slow reply, I have a lot happening here.

Here are a few things I'd like you to try.

First, a simple fullscreen py5 sketch:

def setup():
    py5.fullscreen()


def draw():
    py5.rect(py5.mouse_x, py5.mouse_y, 10, 10)


py5.run_sketch()

Next, replace fullscreen() with size() and add some extra params to run_sketch():

def setup():
    py5.size(500, 500)


def draw():
    py5.rect(py5.mouse_x, py5.mouse_y, 10, 10)


py5.run_sketch(py5_options=["--present", "--window-color=#ff00cc"])

@villares , those py5_options run the Sketch in presentation mode with a nice background for the area needed to fill the screen.

Next, in the Processing PDE, try running this Java code:

void setup() {
  fullScreen();
}

void draw() {
  rect(mouseX, mouseY, 10, 10);
}

If the above py5 Sketches in Python don't work, I would suspect Processing has some system problem that keeps it from running full screen, and the last example won't work either.

@cabakasap
Copy link
Author

Hello @hx2A and @villares. @hx2A, I tried all of the options you mentioned above. None of them seems to be working. For the last sketch, I am using Thonny as an editor, not Processing PDE so I could not estimate where I have to place the Java code. But since the first part did not work, I do not think that this last Java part will work either.

@villares
Copy link
Collaborator

villares commented Oct 7, 2024

I am using Thonny as an editor, not Processing PDE so I could not estimate where I have to place the Java code.

Just out of curiosity, if you have the time, you can download the Processing IDE (PDE) from https://processing.org/download

@hx2A
Copy link
Collaborator

hx2A commented Oct 7, 2024

@cabakasap , there might be an issue with your computer where it is not happy running Java Sketches fullscreen. I suspect that if you download and install the Processing PDE and run that last Java example, it won't work either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants