This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Trying to debug an application hang on dlclose but need some insight


I have been experimenting with an application called OpenSceneGraph.  It uses 
several dll's.  About half its test applications work but the other half do not 
and will run but hang on close.  I have been working with them trying to 
identify the hangs.  It seems the hangs occur with one particular .dll from 
what I can tell and occurs at the point of close.  I'm guessing the problem was 
already completed before we get to this point but...  here is what I have so 
far.  I compiled cygwin using the debug options I found in a thread and then 
copied the cygwin0.dll to cygwin1.dll and copied the .dbg file (both to /bin). 
I start one of the simple tests in gdb, set a breakpoint on dlclose and 
initiate the run:

(gdb) run cow.osg
Starting program: /usr/local/bin/osgconvd.exe cow.osg

Breakpoint 3 at 0x61020164: file 
/usr/develop/src/src/src/winsup/cygwin/dlfcn.cc
, line 146.
Pending breakpoint "dlclose" resolved
Loaded symbols for /cygdrive/c/WINDOWS/system32/ntdll.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/kernel32.dll
Loaded symbols for /usr/bin/cygwin1.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/advapi32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/rpcrt4.dll
Loaded symbols for /usr/local/bin/cygosgDBd-1.9.5.dll
Loaded symbols for /usr/local/bin/cygOpenThreadsd-1.9.5.dll
Loaded symbols for /usr/local/bin/cygosgd-1.9.5.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/glu32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/msvcrt.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/opengl32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/gdi32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/user32.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/ddraw.dll
Loaded symbols for /cygdrive/c/WINDOWS/system32/dciman32.dll
Loaded symbols for /usr/local/bin/cygosgUtild-1.9.5.dll
itr='/usr/local/bin'
FindFileInPath() : trying /usr/local/bin/cygosgdb_osg.dll ...
FindFileInPath() : USING /usr/local/bin/cygosgdb_osg.dll
CullSettings::readEnvironmentalVariables()
CullSettings::readEnvironmentalVariables()
Opened DynamicLibrary cygosgdb_osg.dll for handle 0x5060000
itr='/usr/local/OpenSceneGraph-data'
FindFileInPath() : trying /usr/local/OpenSceneGraph-data/cow.osg ...
FindFileInPath() : USING /usr/local/OpenSceneGraph-data/cow.osg
itr='/usr/local/bin'
FindFileInPath() : trying /usr/local/bin/cygosgdb_rgb.dll ...
FindFileInPath() : USING /usr/local/bin/cygosgdb_rgb.dll
Opened DynamicLibrary cygosgdb_rgb.dll for handle 0x71b0000
itr='/usr/local/OpenSceneGraph-data'
FindFileInPath() : trying /usr/local/OpenSceneGraph-data/Images/reflect.rgb ...
FindFileInPath() : USING /usr/local/OpenSceneGraph-data/Images/reflect.rgb
raw->sizeX = 128
raw->sizeY = 128
raw->sizeZ = 3
raw->bpc = 1
image read ok 128  128
Time to load files 10476.2 ms

Stats before:
Object Type     #Unique #Instanced
StateSet        1       1
Group           1       1
Transform       0       0
LOD             0       0
Switch          0       0
Geode           1       1
Drawable        1       1
Geometry        1       1
Vertices        7772    7772
Primitives      5804    5804
Optimizer::optimize() doing REMOVE_LOADED_PROXY_NODES
Optimizer::optimize() doing COMBINE_ADJACENT_LODS
Optimizer::optimize() doing OPTIMIZE_TEXTURE_SETTINGS
Optimizer::optimize() doing SHARE_DUPLICATE_STATE
Num of StateSet=1
state attribute list
    0x10d8b280  TexGen
    0x10d8a520  Material
    0x10d8aa18  Texture2D
searching for duplicate attributes
Optimizer::optimize() doing FLATTEN_STATIC_TRANSFORMS
** RemoveStaticTransformsVisitor *** Pass 0
Optimizer::optimize() doing CHECK_GEOMETRY
Optimizer::optimize() doing MERGE_GEOMETRY
MERGE_GEOMETRY took 2.01143e-05
Optimizer::optimize() doing REMOVE_REDUNDANT_NODES

Stats after:
Object Type     #Unique #Instanced
StateSet        1       1
Group           1       1
Transform       0       0
LOD             0       0
Switch          0       0
Geode           1       1
Drawable        1       1
Geometry        1       1
Vertices        7772    7772
Primitives      5804    5804
Data written to 'converted.osg'.
Closing DynamicLibrary cygosgdb_osg.dll for handle 0x5060000

Breakpoint 3, dlclose (handle=0x0)
    at /usr/develop/src/src/src/winsup/cygwin/dlfcn.cc:146
146     {
(gdb) 

NOTE the handle printed above is the handle the the program believes belongs 
that dll but it simple a straight print and no formatting so not sure how it 
relates to how it should be truly shown for checking.

Once I hit my break on dlclose I begin to step through.  As you can see above 
the last thing the programs debug out printed was that it was closing the dll.  
On some of the apps other dlls they will close and return with a statement 
saying they closed successfully. This one though as I step through I get this:

(gdb) whatis handle
type = void *
(gdb) print handle
$1 = (void *) 0x0
(gdb) s
dlclose (handle=0x610b85e8)
    at /usr/develop/src/src/src/winsup/cygwin/dlfcn.cc:147
147       int ret = -1;
(gdb) print handle
$2 = (void *) 0x610b85e8
(gdb) s
148       void *temphandle = (void *) GetModuleHandle (NULL);
(gdb) print handle
$3 = (void *) 0x610b85e8
(gdb) bt
#0  dlclose (handle=0x610b85e8)
    at /usr/develop/src/src/src/winsup/cygwin/dlfcn.cc:148
#1  0x0022ce64 in ?? ()
#2  0x10d64698 in ?? ()
#3  0xffffffff in ?? ()
#4  0x610b85e8 in _sigfe ()
    at /usr/develop/src/src/src/winsup/cygwin/cygtls.h:230
#5  0x00000000 in ?? ()
(gdb) s
    217 [sig] osgconvd 2144 open_stackdumpfile: Dumping stack trace to 
osgconvd.
exe.stackdump

Program exited with code 01.
(gdb) quit

BrianK@atl-lt-5783 /usr/tmp
$

after the stackdump I have to kill the program with windows Taskmanager.  If I 
read the above correctly the handle that dlclose is seeing is related to _sigfe 
in cygtls.h which looking at line 230 appears to be in the reset_fault logic 
and I am guessing is not related to the dll we were supposed to close at all?

Is this telling me something occured before I ever got this far IE that is why 
we are in a reset_fault method and # 5 in the stack is all zero.  What would 
cause the stackdump at line 

148 void *temphandle = (void *) GetModuleHandle (NULL);

when that line is executed since from what I read on GetModuleHandle the use of 
the NULL is perfectly acceptable.  Any thoughts/explanation/theories would be 
greatly appreciated.






--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]