Forums

Running task results in strange errors after image upgrade

A couple months pythonanywhere made me upgrade my server image. Ever since, the scheduled hourly task I have occasionally gets strange errors and won't start.

The errors are hard to reproduce because 1) they only happen occasionally and 2) they tend to be different each time. I also can't troubleshoot them because they are not python errors and they don't have line numbers.

My task is simply cd /home/zadieblack/bot3 && python3.8 run_as_task.py

Some of the errors I've gotten are

/bin/bash: line 1:    24 Segmentation fault      python /bin/run_scheduled_task.py 'cd /home/zadieblack/bot3 && python3.8 run_as_task.py'

corrupted size vs. prev_size
/bin/bash: line 1:    24 Aborted                 python /bin/run_scheduled_task.py 'cd /home/zadieblack/bot3 && python3.8 run_as_task.py'

munmap_chunk(): invalid pointer
/bin/bash: line 1:    24 Aborted                 python /bin/run_scheduled_task.py 'cd /home/zadieblack/bot3 && python3.8 run_as_task.py'

Again, my code is python (obviously) but these seem to be C errors and they don't have line numbers. They also aren't consistent. Sometimes the task will run fine for a while, then all of a sudden it will get a bunch of these weird errors. They didn't happen before the server image update.

Any ideas?

One more thing, if I run these same commands manually in bash they work fine. I don't get any of these errors at all when I do this from the command line.

Was the console where you're successfully running your code created before or after the system image change? What kind of dependencies your script uses?

Hmm interesting idea about the consoles. So, I just created a new console and ran the code from that and it does get the errors. I don't know whether to count that as progress or not lol. It seems to alternate between the 'corrupted size' error, the 'mummap_chunk' error and then occasionally it runs perfectly fine.

My code references a bunch of python libraries. Most of them are pretty standard though:

re, sys, decimal, random, os, time, enum, argparse, as well as PIL (pillow). There may be a couple others as well, there are a lot of files.

OK, the console experiment proves that it's system image related. Is your script using any packages that you installed on the previous system image? If so, did you try reinstalling them (purging ~/.cache directory before that, if you don't keep anything critical there, might also help).

OK. I have uninstalled, cleared cache, and reinstalled all the pip packages I'm aware of that were installed just for this script. Also upgraded them where needed. Unfortunately the issue persists. I am now putting print statements in the code trying to narrow down exactly where the errors are happening. Haven't got it nailed down yet but my suspicions are that it is the Pillow library (for image processing).

Certainly Pillow sounds like a likely culprit, given that it's quite heavy on C code, and it a segfault is almost certainly coming from a bug in some C code. But it will be interesting to see what your experiments show up in terms of what kind of code is triggering the issue.