[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <xavier.leroy@i...> |
| Subject: | Re: [Caml-list] Threads + Win32 API = crash |
> I'm having trouble incorporating multithreading support into my OCaml-Win32
> library. Basically, any program that uses OCaml threading and also invokes
> a Win32 message loop will crash after a few seconds with an illegal attempt
> to access memory at "0x00000001". This behavior is demonstrated by the
> enclosed sample program, which is very simple and does not require my
> OCaml-Win32 library.
> I don't really know how to investigate this problem further. I've
> determined that the problem goes away if I disable the tick thread
Several users reported similar problems with threads under Windows in
OCaml 3.04. After investigation, I found that I managed to break the
timer-based preemption while trying to work around another issue in
the Windows port.
If you're willing to recompile from sources, here is the fix: in
byterun/signals.c, replace
CAMLexport void leave_blocking_section(void)
{
#ifdef _WIN32
/* Under Win32, asynchronous signals such as ctrl-C are not processed
immediately (see ctrl_handler in win32.c), but simply set
pending_signal and let the system call run to completion.
Hence, test pending_signal here and act upon it, before we get
a chance to process the result of the system call. */
int signal_number = pending_signal;
pending_signal = 0;
if (signal_number) execute_signal(signal_number, 1);
#endif
if (leave_blocking_section_hook != NULL) leave_blocking_section_hook();
Assert(async_signal_mode);
async_signal_mode = 0;
}
by
CAMLexport void leave_blocking_section(void)
{
#ifdef _WIN32
int signal_number;
#endif
if (leave_blocking_section_hook != NULL) leave_blocking_section_hook();
#ifdef _WIN32
/* Under Win32, asynchronous signals such as ctrl-C are not processed
immediately (see ctrl_handler in win32.c), but simply set
pending_signal and let the system call run to completion.
Hence, test pending_signal here and act upon it, before we get
a chance to process the result of the system call. */
signal_number = pending_signal;
pending_signal = 0;
if (signal_number) execute_signal(signal_number, 1);
#endif
Assert(async_signal_mode);
async_signal_mode = 0;
}
Hope this helps,
- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners