Rovango / cefpython

Automatically exported from code.google.com/p/cefpython
0 stars 0 forks source link

Application error in python.exe when closing main browser window #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It's a random error happening on application exit. I am able to reproduce it 
right now by doing a lot of clicks in the window, then closing it. The exact 
error message below:

python.exe - Application Error
---------------------------
The instruction at "0x7ca712b7" references memory at "0x00c5fe28". The memory 
could not be "read".
Click on OK to terminate the program
---------------------------

It sometimes references to "0x00c5feb0".

I tried running WinDbg but failed even to start the script with it, getting 
some kernel errors.

I tried running Spy++ and I see something strange happening in the top window 
(top-right of the screen), a WM_CLOSE message is called after WM_NCDESTROY. 
That window is created using pywin32 extension. There are 2 other inner windows 
created by CEF, but they seem to have proper messages,  there are no more 
messages processed after WM_NCDESTROY which is a correct behavior. Attaching 
!Spy++ screenshot.

Original issue reported on code.google.com by czarek.t...@gmail.com on 8 Jul 2012 at 8:14

Attachments:

GoogleCodeExporter commented 8 years ago
To the left of message id ex. WM_CLOSE there is a letter, one of "S", "P", "R", 
their meaning are:

S - the message sent using SendMessage()
P - using PostMessage()
R - denotes return value for SendMessage()

Maybe we should PostMessage to destroy the main window so that we can return 
immediately from WM_CLOSE and the order in these messages is correct.

Original comment by czarek.t...@gmail.com on 8 Jul 2012 at 8:41

GoogleCodeExporter commented 8 years ago
Success. In CloseApplication() [cefadvanced.py and cefsimple.py] I've replaced:

> cefwindow.DestroyWindow(windowID)
with:
> win32api.PostMessage(windowID, win32con.WM_DESTROY, 0, 0)

And now order of messages in Spy++ is correct, "S WM_CLOSE", "R WM_CLOSE", "R 
WM_SYSCOMMAND" and the last "P WM_DESTROY".

In WM_CLOSE and WM_DESTROY procedures "return 0" statement can be omitted.

If I put "return win32gui.DefWindowProc()" after PostMessage() then the order 
of messages in Spy++ is wrong again, so don't do it.

I've been clicking and closing windows for a few minutes and it seems that 
everything works fine now. I will be testing it for the next few days, if there 
are no errors on exit then I will close this issue.

Original comment by czarek.t...@gmail.com on 8 Jul 2012 at 9:12

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

Original comment by czarek.t...@gmail.com on 12 Jul 2012 at 10:39

GoogleCodeExporter commented 8 years ago
This issue is still not properly fixed, errors of "memory cannot be read" when 
closing browser are still appearing on windows 2003.

Original comment by czarek.t...@gmail.com on 21 Aug 2012 at 12:20

GoogleCodeExporter commented 8 years ago
Issue in CEF has been reported:
http://code.google.com/p/chromiumembedded/issues/detail?id=700

Original comment by czarek.t...@gmail.com on 22 Aug 2012 at 6:30

GoogleCodeExporter commented 8 years ago
This issue still persists in XP.

Original comment by alex.na...@gmail.com on 24 Aug 2012 at 4:16

GoogleCodeExporter commented 8 years ago
In issue 700 on CEF:
http://code.google.com/p/chromiumembedded/issues/detail?id=700

Marshall has provided a solution. But to test it I will have to compile 
Chromium sources + CEF sources and build my own binaries, it can take time as 
it's probably not an easy task.

Original comment by czarek.t...@gmail.com on 24 Aug 2012 at 5:03

GoogleCodeExporter commented 8 years ago
@alex.nanou:

In the meantime there is a solution, it's not perfect as CEF won't do cleanup 
after itself (scoped_dir/ in temp/) but it should get rid of error.

In QuitApplication() replace "win32gui.PostQuitMessage(0)" with this line:

    os.kill(os.getpid(), 9)

(one might also try sys.exit(0) or os._exit(0) - which are less drastic)

Original comment by czarek.t...@gmail.com on 24 Aug 2012 at 5:21

GoogleCodeExporter commented 8 years ago
Update to temporary solution.

In QuitApplication() replace "win32gui.PostQuitMessage(0)" with this lines:

    cefpython.Shutdown()
    os.kill(os.getpid(), 9)

Original comment by czarek.t...@gmail.com on 24 Aug 2012 at 6:34

GoogleCodeExporter commented 8 years ago
It would be be even better to put os.kill after the loop and shutdown, without 
modifying QuitApplication(), but I'm not sure whether it would fix the error, 
but worth checking. In CefAdvanced() add os.kill after MessageLoop() and 
Shutdown():

    cefpython.MessageLoop()
    cefpython.Shutdown()
    os.kill(os.getpid(), 9)

Alex can you confirm that this fixes the error?

Original comment by czarek.t...@gmail.com on 24 Aug 2012 at 6:44

GoogleCodeExporter commented 8 years ago
At this point it's not critical, for me at least, the software I'm working on 
is not yet public and will not be out for several weeks... so I'm not digging 
in this particular issue yet.

BTW, neither workaround seems to work.

Original comment by alex.na...@gmail.com on 25 Aug 2012 at 9:13

GoogleCodeExporter commented 8 years ago
I have a report from other user that os.kill() called after shutdown fixes the 
error. Please describe your error in more details as this seems like some other 
bug. Try putting os.kill in one of 3 places: in CloseApplication(), in 
QuitApplication(), after Shutdown() - one of them must fix the problem.

Original comment by czarek.t...@gmail.com on 25 Aug 2012 at 9:24

GoogleCodeExporter commented 8 years ago
Are you using latest 0.35 version?

Original comment by czarek.t...@gmail.com on 25 Aug 2012 at 10:19

GoogleCodeExporter commented 8 years ago
version 0.35, as before.

kill after Shutdown works.

Original comment by alex.na...@gmail.com on 26 Aug 2012 at 5:32

GoogleCodeExporter commented 8 years ago
Putting os.kill after Shutdown() is the best place for it.
Use this solution until this issue is fixed.

Original comment by czarek.t...@gmail.com on 26 Aug 2012 at 5:59

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I am unable to compile Chromium on WinXP, from what I read building chrome on 
XP is not supported anymore, command line arguments passed to compiler are too 
long and builds fail. I am going to need Win7 and a new hdd to build it.

Original comment by czarek.t...@gmail.com on 1 Sep 2012 at 7:39

GoogleCodeExporter commented 8 years ago
I've successfully compiled Chromium, branch 1025 revision 607.
I've created 2 zip binaries to test.

1. Issue 2 test 1:

First we need to test whether to bug still persits, so use "test 1" to confirm 
the bug, app should crash when closing window while running this test.

http://code.google.com/p/cefpython/downloads/detail?name=issue2_test1_0.38_py27.
zip&can=2&q=#makechanges

2. Issue 2 test 2:

This binaries have the Marshall's patch applied, this should fix the crash when 
closing app.

http://code.google.com/p/cefpython/downloads/detail?name=issue2_test2_0.38_py27.
zip&can=2&q=#makechanges

Alex, let me know whether this fixes the problem.

Original comment by czarek.t...@gmail.com on 3 Sep 2012 at 9:45

GoogleCodeExporter commented 8 years ago
Have a report from Cjjer that test2 still didn't fix the error. Will report 
that to Marshall, we will have to wait for some other fix.

Original comment by czarek.t...@gmail.com on 3 Sep 2012 at 9:56

GoogleCodeExporter commented 8 years ago
i am cjjer.

windows2003 sp2,all test has the error.

Original comment by cjjer....@gmail.com on 3 Sep 2012 at 9:57

Attachments:

GoogleCodeExporter commented 8 years ago
With big help of Cjjer, after many hours of testing we have this error fixed, 
I've made some minor modifications to the fix so it still needs some testing, 
here is the final test:

Test 6 should resolve this issue:
http://code.google.com/p/cefpython/downloads/detail?name=issue2_test6_0.38_py27.
zip

Original comment by czarek.t...@gmail.com on 3 Sep 2012 at 3:19

GoogleCodeExporter commented 8 years ago
This issue is related to our problem:
"CEF1: Eliminate use of scoped directories"
http://code.google.com/p/chromiumembedded/issues/detail?id=670

Original comment by czarek.t...@gmail.com on 3 Sep 2012 at 9:46

GoogleCodeExporter commented 8 years ago
Cjjer confirmed that test 6 fixes the error. This fix will make it into next 
release.

Original comment by czarek.t...@gmail.com on 4 Sep 2012 at 6:44

GoogleCodeExporter commented 8 years ago
Version 0.38 released.

Original comment by czarek.t...@gmail.com on 4 Sep 2012 at 9:18

GoogleCodeExporter commented 8 years ago
This bug has been fixed in CEF sources in revision `827`:
http://code.google.com/p/chromiumembedded/source/detail?r=827

Original comment by czarek.t...@gmail.com on 21 Nov 2012 at 6:02

GoogleCodeExporter commented 8 years ago
Project will move to Github. Find this issue at the new address (soon): 
https://github.com/cztomczak/cefpython/issues/2

Original comment by czarek.t...@gmail.com on 24 Aug 2015 at 6:23