Sh

Issue319

Title Stream programs crash on exit (on Windows)
Priority bug Status chatting
Difficulty Milestone 0.8.0
Superseder Nosy List francois, pan
Assigned To Topics

Created on 2006-02-11.00:31:14 by francois, last changed 2006-05-23.12:19:31 by mikrima.

Issue summary

This report covers a crash that happens when stream programs shut down on Windows. Below you'll find the symptoms that were reported, the suspected cause in the backend destruction path, and the workarounds and fixes that were attempted.

Messages
msg941 (view) Author: mikrima Date: 2006-05-23.12:19:31
I noticed the same problem - crash on exit.
It happens in a glDeleteTextures() call. At this point, the OpenGL context seems
not to exist anymore. Any other calls to OpenGL failed as well. 
For my own purposes, I removed the call to glDeleteTextures() and everything
works fine now.
I think, the order in which the OpenGL context and the objects are destroyed is
messed up, but I haven't further investigated in the matter.
msg888 (view) Author: francois Date: 2006-02-13.22:32:21
This seems to be a problem with every stream program on Windows.  The sample
code on the Sh Wiki also causes this crash.
msg886 (view) Author: francois Date: 2006-02-13.22:07:35
This has apparently nothing to do with the "particles flying into space" bug
(issue320).
msg883 (view) Author: francois Date: 2006-02-13.21:31:24
The crash in particles is different.  I get the following error message:
 NVOpenGLPbuffer: ShParticleExample.exe - Application Error
 The exception unknown software exception (0xc0000005) occured in the
application at location 0x5e8d532e.
msg882 (view) Author: francois Date: 2006-02-13.21:28:50
r3523 should fix the issue with the Binding example.  I have removed the
offending new/delete calls since that stuff is now handled by the
(non-windows-specific) backend instantiation code.
msg881 (view) Author: pan Date: 2006-02-11.12:49:27
I'm having the same problem.
I noticed that the arb backend's destructor is being called twice, recursively.
The outer destruction starts while DLL_PROCESS_DETACHing, while the other 
spawns while removing the backend from the backend's list (destruction of the 
shared pointer inside the static map of backends 
ShBackend::m_instantiated_backends).
The problem could be avoided either by converting the ShPointer<ShBackend> in 
BackendMap to a standard ShBackend* (this will solve THIS problem, but more 
will arise from the others ShPointer<ShBackend> around).
Another, more complex solution could be letting ShBackend manage the memory and 
add some functions to register, instantiate and deinstantiate the backend onto 
ShBackend, and replacing the new/delete couple with.
Anyway, the instantiation/deinstantiation of a Backend is a bit confused.
I think that the thing will broke anyway if you run two applications sharing 
the same dlls.
It's not very clear to me if a backend-derived class should be a per process 
singleton, a cross process singleton or just an object as the others (I'm 
referring to the arb backend in particular, but I think this will apply to the 
other backends, too):
By the code in dllmain it looks like a per process singleton (every attached 
process create a new backend). 
On the other hand, the code in ShBackend seems to link the life of the only 
ArbBackend to the life of the libsh dll, so it looks like a cross process 
singleton, since the registration is linked to construction of a subclass and 
deregistration of linked to destruction of a subclass.
On the other hand again (third one?) the shBackend_libsharb_instantiate can be 
used to create another backend, and I can't catch this one.
Is this a design issue, or it's just me not being able to catch the 
instantiation mechanism?
msg879 (view) Author: francois Date: 2006-02-11.00:31:14
Simply run the particle or the binding example, press space so that the
particles/polygon start moving.  Then press 'q' to quit.  You will get an error
message like:
  "The instruction at 0x5ed0530e referenced momory at 0x0000051c.  The memory
could not be read."

Frequently Asked Questions

What does Issue 319 cover?

Issue 319 describes stream programs crashing when they exit on Windows. The crash showed up while running the particle and binding examples and pressing 'q' to quit.

Which programs does it affect?

Based on the discussion, the problem shows up with every stream program on Windows, including the sample code on the Sh Wiki.

What triggers the crash?

Contributors observed that the crash occurs inside a glDeleteTextures() call once the OpenGL context no longer exists, and that the arb backend's destructor runs twice, recursively, during DLL_PROCESS_DETACH and while the backend is being removed from the backend's list.

Is there a workaround?

One reporter dropped the glDeleteTextures() call and said everything worked fine afterwards. Revision r3523 was noted as fixing the Binding example issue by removing the offending new/delete calls.

Does this relate to the particles flying into space bug?

No. The discussion notes this appears to have nothing to do with the "particles flying into space" bug tracked as issue320.

What is the current status?

The issue carries status "chatting" and milestone 0.8.0, with francois and pan on the nosy list.

History
Date User Action Args
2006-05-23 12:19:31mikrimasetmessages: + msg941
2006-04-03 21:56:10francoissetassignedto: francois ->
2006-03-01 16:54:39francoissettitle: Particle example crashes when it exits (on Windows) -> Stream programs crash on exit (on Windows)
2006-02-13 22:47:41francoissetmilestone: 0.8.0rc1 -> 0.8.0
2006-02-13 22:32:21francoissetmessages: + msg888
milestone: 0.8.0 -> 0.8.0rc1
2006-02-13 22:07:39francoissetmessages: - msg884
2006-02-13 22:07:35francoissetmessages: + msg886
2006-02-13 21:33:43francoissetmessages: + msg884
milestone: 0.8.0rc1 -> 0.8.0
2006-02-13 21:31:24francoissetmessages: + msg883
title: Particle and Binding examples crash when they exit (on Windows) -> Particle example crashes when it exits (on Windows)
2006-02-13 21:28:50francoissetassignedto: francois
messages: + msg882
milestone: 0.8.0 -> 0.8.0rc1
2006-02-11 12:49:28pansetstatus: unread -> chatting
nosy: + pan
messages: + msg881
2006-02-11 00:31:14francoiscreate