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
Stackless 2.7.* app crash #165
Comments
Can you please provide a minimal example. My Cython experience is very limited and I'm not sure, that I can create my own example. I need to run the example with a debug build of Stackless. |
I do not know how you go about compiling python-openzwave on linux so I can't give any instruction in that area. If you are on windows you will need to download the attached file. the file is a clone of python-openzwave that has been modified to properly build on Windows. you will need to have Visual Studio 15.0 installed with all the Visual C plugins installed. I have the Visual C++ compiler package for python 2.7 installed. I do not think this is used but i can't remember. I also have all of the Visual C++ redists installed from 2008 to 2017 I don't remember off hand which ones are used. You are also going to have to use the Visual Studio installer and install the Windows 10 SDK (latest one). after you have done all of that then you can run the builder. to launch the builder
This will only build it not install. It will clone the openzwave repo and make any changes that are necessary to perform a successful build. it will take a while for it to locate VS and to run vcvars32 grab the environment settings from the subprocess and apply them to the environment that the builder is running in . it also has to modify the solution for openzwave because it was it was made to compile with VS 2010 which is pretty difficult to locate. once the build process for openzwave starts it will take a while to complete. you should have more then one line of "."s, if it completes really fast then something is wrong. once openzwave has finished building it will state that it is cythonizing and that is when the crash occurs. This is about as minimal as i can provide. I do not know a lot about cython either. It might be easier if you have a debugging build of stackless done for Windows and tell me what is needed have me run the tasks. or if you want to RDP into my machine using TeamViewer and run whatever it is you need to. we can do that as well. here is the attachment if you are able to use it |
OK so i am not sure exactly what was causing the issue but i ran a build of openzwave using msbuild instead of visual studio. and when Cython ran no exception everything seems to be good. I do not know what caused the issue because I am using the same msbuild that VS is using. I am passing the solution right to msbuild. Not sure. but the problem has gone away. I did have my PS in my PC die. and I installed a new one. but i do not think this would have caused a problem. who knows. |
There is indeed a problem. I just tried to run the Cython test suite with a Stackless 2.7.15 debug build and got a SystemError exception. I'm going to debug this issue, but it will take some time. |
That's what it is. I got the same error also. but it stated the issue was in logging.py when I added a null handler. It stated "SystemError no exception set". or something to that effect. It could be a place to look. I do not know if that is actually where the problem is or not. the strange thing is I removed the logging code from the Cython file that got compiled but the same error showed up. exactly the same way. So it could be that is the issue I simply do not know where it is coming from. |
I am told by the folks over at cython that everything works as advertised with the Stackless 3.* builds. not sure if that may help you locate the issue or not. |
@kdschlosser : probably your problems were caused by #166. I'll provide you a fixed python27.dll within a few days. Do you use the 32bit or the 64bit version? |
I am using 32 bit. I also wanted to say thank you very much for locating and solving the problem so quickly. most view python 2 as not worth fixing problems with because it is going to become EOL not to long from now. Unfortunately our project is stuck with it for a while because of slow development with wxPython and python 3. This fix is going to allow us to add a very needed piece of functionality to our software. I know I probably wasn't a huge help in giving clues. I am still newish to the programming world and this sort of thing is over my head. But I am learning. Thank You for the time you have spent working on this. Fixing this has removed the need for those changes I made that got deleted by the stackless installer. It is also going to provide a much cleaner means of adding functionality to our software. |
I'm in a similar situation. We have a product, that is based on the capability to serialize (pickle) tasklets and continue them later on a different host with a different OS. That's currently not possible with C-Python. Btw. here is the archive with the new python27.dll: https://bitbucket.org/stackless-dev/stackless/downloads/StacklessPythonDLL_32bit_2.7.15_git-d377c06344.zip. Just replace the python27.dll in your installation with this one. |
Thanks so much for getting this fixed as fast as you have I really do appreciate it. Do you or Stackless have any mechanism to be able to donate? You have no idea how much work this is going to save me. The way I was going to go about adding this addition to our software was I was going to create a separate installation for just this feature what would run as a service and open a socket that i would connect to from the software that runs on Stackless. to many extra bits involved that don't need to be there if i can access the code directly. If you ever get the opportunity and want to check out what we do it's at www.eventghost.net. we have to be one of the older pieces of software running Stackless. coding started on 8-10-2005. initial release i think was early 2007. maybe you can suggest something that may improve functionality/performance, who knows. I started working on the project 2 years ago and have not had the opportunity to look into how Stackless functions. We had discussed removing it because of the website and the issues there made it seem like it was basically still being distributed but not really developed, This was brought up on several forums and the general consensus was that Stackless was no longer being developed. I do have this question, I have searched the internet for an answer and only found half answers mostly "I heard this", or "I read this somewhere" not solid answers, not a single clear answer. I really have been wanting a clear answer to.. |
Well we are much closer then before. I am still getting an app crash. But it compiles and the import works correctly. It starts the connection to the hardware and then part way through it. it crashes
visual studio debugger is telling me that the issue is in python\ceval.c line 1427
I can give you a copy of the code I am using, i don't think it is going to help unless you own a 5th Generation Aeon Labs ZStick |
About the development of Stackless: currently I'm maintaining Stackless, because my company still needs Stackless 2.7.x. Probably we will have to port our application to Stackless 3.x within the next two years. Therefore I'm very much interested in fixing bugs, but not in adding features. And I don't care about the Web-Site very much. What are the benefits of Stackless Python over Traditional Python? Stackless tasklets are a kind of coroutine or micro-thread. This makes it possible to write web-servers for many thousands connected clients, because switching tasklets is much faster than switching os-level threads. Another unique feature of Stackless is the option to pickle a tasklet and restore it later. This can be used to checkpoint a program or to migrate it to a different computer. About your crash. The python27.dll is PGO-optimized. Don't rely on the debugger, it may misguide you. If you have VS2008 you should really create a Debug Build of Stackless. Not only the debug build is not optimized. More important are the assertions, which are enabled in debug builds. And if you suspect a problem in Python/ceval.c you really should comment out the line Once you have a debug build you need to write a minimal example that reproduces the crash. This can take a lot of time. But I can't help you without such an example. With Cython you had good luck. There was a discussion on the python-dev mailing list about a new C-API for fast function calls and Cythons fast function calls were mentioned. Therefore I was aware of potential problems with Cython. And indeed the Cython test suite failed. |
OK I will see if i can do that for ya. I also found a copy of Visual Studio 2008 Pro that does not require a 550.00 USD yearly subscription. Apparently Microsoft still has a 90 day evaluation copy they may have forgotten about on one of their servers. so for anyone interested it is located here and there is also a service pack that is available. and that is located here |
Good writeup, Anselm. Pickling of execution state really always was a super feature. Although strictly speaking it doesn't stem from the existence of "tasklets", but rather how stackless doesn"t rely on a recursive frame execution loop. |
I am sorry for bother you again. All of this stuff is clearly over my head. I have built the debugging version of stackless (2.7-slp branch) Visual studio loads everything properly when debugging the crash You are correct as far as the debugging information i gave you before not being correct. it now points to a different spot. Please bear with me here as i think i am going about getting the proper information. I have not a clue how I would go about creating this problem outside of using the code that I have. I did not write this code I am using it to connect with a device on my system. I am still a ways off from being able to fully understand what is happening with all of this. But this is what I am seeing. This is the error that shows up when i run the project I am workin on,
Now i know that none of this is going to make any sense to you. But basically it is logging output for the communications between the software and the device as well as communications between the device and wireless devices that it is communicating with. The big thing is all of this code is located inside of the pyd file that was compiled with the dll you posted earlier being in place. This is a big step because i was never even able to import the pyd file let alone even get it to run. So this is a good thing. it compiles, it loads. and it runs mostly. when i bring up the call stack in Visual Studio and show the source for where the breakpoint occured this is what gets shown. This is from ceval.c
This is how i think all of this works. so don't quote me on this and please correct me if i am wrong. Cython generates cpp code by using a user created .pyx file. this is the next item down the call stack. This is from the .cpp file that is created by Cython
I am not sure if there is a way to take another step into the code chain and manage to get the location in the pyx file that is making the call to __Pyx_PyFunction_FastCallNoKw to see if maybe the issue can be handled there or to see how exactly to write a Cython pyx file to give you a minimial code block to replicate this issue. If this information is of no help I can ask over at the Cython repository and see if someone there could write something up that can cause this issue. But i figured I would start here because of the comments right before the code that is generating the assertion error. which is that it is checking to make sure stackless is initialized. as it would appear that it is not. Now that comment got me thinking |
Update: I tried creating a tasklet and the same error still comes up. |
@kdschlosser Hi Kevin, we have a good starting point. Is your code multi threaded?
and report, which line fails. This way we get more information. Usually this assertion fails, if a new thread has been created outside of Python and the Stackless thread state has not been initialized. Most entry points into Stackless Python have special code for this situation, but I didn't add this code to PyEval_EvalFrameEx(). Instead I added just the assertion. @kristjanvalur Kristján, do you have any suggestion how to initialize the tstate in this situation? It is a bit different from the usual "Stackless external interface" code in stacklessmodule.c. |
OK I will make those changes and report back to ya. I don't know how long it is going to take for stackless to compile it took 10 minutes to make the debug version so it should be that or less. |
ok this was quick.
and to answer you question on the multi threading. I am assuming you want to know about the pyd file. and the answer is yes it is. Tho I do not know when the threads are created. it could be at module import. maybe importing the pyd file inside of a tasklet? I can give that a shot. |
nope that didn't work. |
Ok, that's fine. Here is a small script, that reproduces the assertion failure.
Now it's easy to fix. |
@kdschlosser Hi Kevin, please try https://bitbucket.org/stackless-dev/stackless/downloads/StacklessPythonDLL_32bit_2.7.15_git-187184ba.zip. It is a PGO optimized build of commit 187184b. I'm pretty confident, that this build fixes the assertion failure. If not, please make an debug build of commit 187184b and report the output. |
ok will do |
Alright! That seems to have fixed the issue. HOORAY! Thank you very much in the lesson on how to use Visual Studio to debug. |
Thank you again for reporting the issue and for your prompt response to my questions. |
hey no worries m8. I am glad you got it all sorted. it helped me a HUGE amount. I am already almost done with coding a plugin for our program. That is how much easier it has become. it would have taken weeks going between writing the code and bug testing before I would have even been able to release it. I should be done with it by tomorrow. |
I wanted to let you know that I tried compiling a Cython project running Stackless 3.5 and I get the same SystemError traceback as I got when using Stackless 2.7 SystemError: error return without exception set |
@kdschlosser Hello Kevin, please open an new issue and provide detailed information.
|
ok will do. |
Here is the setup.
Windows 7 x64 sp1
Stackless Python 2.7.* x32
Cython 0.28.3
I am compiling python-openzwave which uses Cython. I get this error when compiling on stackless 2.7.* and not on standard python 2.7.*.
I get a Python app crash as soon as it starts cythonizing.
Here is the data from the app crash window
The project I am working on has been around since 1996 and Stackless Python was used and is not something that can be removed easily I am also not able to upgrade the python version to 3+ any time soon. I have brought up this error to the author(s) of Cython. they were kind enough to add Stackless to their test build on travis. they found that 2.7 fails completely and 3.5 (i believe) builds successfully. they are not compiling the same code as me so that is now removed from the equation. they are building on linux. so the OS has now been removed. If I take the dll (pyd) that is built on standard 2.7 and bring it over to stackless 2.7 I get the exact same app crash on import. This leads me to believe the problem is not with Cython but instead it is with Stackless Python.
I searched the internet to see if anyone has had an issue with the 2 working together and I could not find any issues. I couldn't find anything on someone running the 2 together either. Pretty much a dead end.
The issue reported to Cython can be viewed here:
cython/cython#2476
Any help is appreciated.
Thanks again.
Kevin
The text was updated successfully, but these errors were encountered: