diff --git a/CHANGELOG b/CHANGELOG index 805cb544d..e1e178cce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -64,6 +64,12 @@ Until now #$ reader macro accepted simple vectors as an argument, what lead to bugs if vector didn't match specific requirements like the element type or the arity. Now we sanitize this. +- thread fix on msvc: on windows importing thread was closing the thread +handler so the thread wakeup wasn't working because the handler is not more valid. + +- import thread wasn't set upping a proper environment: on some case +the thread was mistakenly thinking that the thread was already registered. + * 16.1.2 changes since 16.0.0 ** API changes diff --git a/msvc/c/Makefile b/msvc/c/Makefile index 15bd498bc..656f2f210 100755 --- a/msvc/c/Makefile +++ b/msvc/c/Makefile @@ -66,7 +66,7 @@ HDIR = $(top_srcdir)\h HFILES = ..\ecl\config.h ..\ecl\atomic_ops.h $(HDIR)\ecl.h $(HDIR)\ecl-cmp.h\ $(HDIR)\object.h $(HDIR)\cs.h $(HDIR)\stacks.h\ $(HDIR)\external.h $(HDIR)\cons.h $(HDIR)\legacy.h\ - $(HDIR)\number.h $(HDIR)\page.h + $(HDIR)\number.h $(HDIR)\page.h \ $(HDIR)\internal.h $(HDIR)\ecl-inl.h $(HDIR)\bytecodes.h \ $(HDIR)\impl\math_dispatch.h diff --git a/src/c/main.d b/src/c/main.d index 3841005d7..981da13c0 100755 --- a/src/c/main.d +++ b/src/c/main.d @@ -201,7 +201,7 @@ _ecl_dealloc_env(cl_env_ptr env) ecl_internal_error("Unable to deallocate environment structure."); #else # if defined(ECL_USE_GUARD_PAGE) - if (VirtualFree(env, sizeof(*env), MEM_RELEASE)) + if (!VirtualFree(env, sizeof(*env), MEM_RELEASE)) ecl_internal_error("Unable to deallocate environment structure."); # endif #endif diff --git a/src/c/threads/process.d b/src/c/threads/process.d index 0b818f397..a53b0ea07 100755 --- a/src/c/threads/process.d +++ b/src/c/threads/process.d @@ -339,14 +339,16 @@ ecl_import_current_thread(cl_object name, cl_object bindings) #ifdef ECL_WINDOWS_THREADS { HANDLE aux = GetCurrentThread(); - DuplicateHandle(GetCurrentProcess(), - aux, - GetCurrentProcess(), - ¤t, - 0, - FALSE, - DUPLICATE_SAME_ACCESS); - CloseHandle(current); + if ( !DuplicateHandle(GetCurrentProcess(), + aux, + GetCurrentProcess(), + ¤t, + 0, + FALSE, + DUPLICATE_SAME_ACCESS) ) + { + return 0; + } } #else current = pthread_self(); @@ -369,7 +371,7 @@ ecl_import_current_thread(cl_object name, cl_object bindings) { cl_object processes = cl_core.processes; cl_index i, size; - for (i = 0, size = processes->vector.dim; i < size; i++) { + for (i = 0, size = processes->vector.fillp; i < size; i++) { cl_object p = processes->vector.self.t[i]; if (!Null(p) && p->process.thread == current) return 0; @@ -407,6 +409,10 @@ void ecl_release_current_thread(void) { cl_env_ptr env = ecl_process_env(); +#ifdef ECL_WINDOWS_THREADS + HANDLE to_close = env->own_process->process.thread; +#endif + int cleanup = env->cleanup; thread_cleanup(env->own_process); #ifdef GBC_BOEHM @@ -414,6 +420,9 @@ ecl_release_current_thread(void) GC_unregister_my_thread(); } #endif +#ifdef ECL_WINDOWS_THREADS + CloseHandle(to_close); +#endif } @(defun mp::make-process (&key name ((:initial-bindings initial_bindings) ECL_T)) diff --git a/src/cmp/cmpmain.lsp b/src/cmp/cmpmain.lsp index 0b8bbfdfe..2a1568fbf 100755 --- a/src/cmp/cmpmain.lsp +++ b/src/cmp/cmpmain.lsp @@ -73,7 +73,7 @@ the environment variable TMPDIR to a different value." template)) #+msvc (defun delete-msvc-generated-files (output-pathname) - (loop for i in '("implib" "exp" "ilk" "pdb") + (loop for i in '("implib" "exp" "ilk" ) for full = (make-pathname :type i :defaults output-pathname) for truename = (probe-file full) when truename