lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Jan Reijnen wrote:
> GetCurrentFiber() never returns NULL so ConvertThreadToFiber() is never 
> called.

Are you sure? This does not match the behaviour of Wine or Win98.
Try this little program:

#include <stdio.h>
#include <windows.h>

int
main(int argc, char **argv)
{
  printf("%p\n", GetCurrentFiber());
  ConvertThreadToFiber(NULL);
  printf("%p\n", GetCurrentFiber());
  return 0;
}

With Wine I get:

(nil)
0x77c229d8

With Win98 I get:

00000000
0051000C

So this indicates that GetCurrentFiber _does_ return NULL for a
newly created process (i.e a subsequent SwitchToFiber() would
crash). Maybe this is different for other Windows versions?

AFAIK GetCurrentFiber() is just a macro that gets the FiberData
pointer from the current TIB. And this pointer is initialized
with NULL (i.e. no Fiber data structure has been allocated).

IMHO my use of GetCurrentFiber() prevents needless calls to
ConvertThreadToFiber() (and a memory leak in Wine). Windows
experts to the rescue -- please correct me if I'm wrong.

Bye,
     Mike