The docs seem to imply that Attach does nothing if the thread is already
attached, so it may simply not be safe to call Detach if you weren't the
one to actually Attach the thread.
Tim
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5270 (20100711) __________
The message was checked by ESET NOD32 Antivirus.
Though, if I'm interpreting his question (and your comment) correctly,
the only way the call stack could not be empty is if his code is in a
thread that already had a VM. In which case GetEnv() will get the
reference, and simply never calling Detach would fix his issue (which
I'm guessing is the case).
Tim