DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2417
Version: 1.3.0


On Windows, unloading the FLTK library from an application that has called
OleInitialize causes instability, but only if no FLTK windows were created
while the FLTK library was loaded.

---

Windows maintains a refcount on calls to OleInitialize, decrementing the
count on OleUninitialize, and cleaning up OLE when the refcount reaches
zero.  When the FLTK library is unloaded it calls OleUninitialize without
making sure it made a previous call to OleInitialize, which makes the OLE
init refcount inaccurate if it was greater than zero when the FLTK library
was loaded.

If an application calls OleInitialize before unloading the FLTK library,
it is possible that the unchecked call to OleUninitialize in the FLTK
library causes the refcount to be decremented to zero prematurely, which 
results in instability in the application.

---

We are experiencing this issue in QuteCsound, a Qt-based front-end for
Csound.  When QuteCsound starts, the Qt GUI library calls OleInitialize. 
When QuteCsound tells Csound to compile an input file, several Csound
plugins are loaded, two of which are implicitly linked to the FLTK
library.  After Csound renders the input file it unloads the plugins,
which causes the FLTK library to be unloaded, too.

Csound does not create an FLTK window unless the compiled input file tells
it to, and it is possible that the FLTK library gets loaded and unloaded
without an FLTK window being created.  In this case, the FLTK library's
unchecked call to OleUninitialize gets paired with the Qt GUI library's
call to OleInitialize instead of the FLTK library's call.

The immediate result is QuteCsound can no longer set text on the system
clipboard.  Down the road, QuteCsound will crash if the user does
something that assumes OLE is still available.

---

For a workaround, we're adding another call to OleInitialize before
allowing the Csound and FLTK libraries to unload.  This may cause the OLE
initialization refcount to get higher and higher if the FLTK library calls
OleInitialize, too, but it's better than letting the refcount reach zero
prematurely.

Cheers,
~ andy.fillebrown


Link: http://www.fltk.org/str.php?L2417
Version: 1.3.0

_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to