From: Xavier Leroy <xavier.leroy@inria.fr>
To: Harry Chomsky <harry@chomsky.net>
Cc: Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Threads + Win32 API = crash
Date: Mon, 15 Apr 2002 16:54:57 +0200 [thread overview]
Message-ID: <20020415165457.B18541@pauillac.inria.fr> (raw)
In-Reply-To: <002d01c1e32c$56ebe190$0200a8c0@harry>; from harry@chomsky.net on Sat, Apr 13, 2002 at 01:46:36PM -0700
> 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
next prev parent reply other threads:[~2002-04-15 14:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-13 20:46 Harry Chomsky
2002-04-15 14:54 ` Xavier Leroy [this message]
2002-04-16 18:06 ` Harry Chomsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020415165457.B18541@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=harry@chomsky.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).