* perl4caml crashed with threads
@ 2005-11-14 2:16 xuzq
2005-11-14 10:09 ` [Caml-list] " Richard Jones
0 siblings, 1 reply; 6+ messages in thread
From: xuzq @ 2005-11-14 2:16 UTC (permalink / raw)
To: caml-list
Hi,
On my debian sid box,the following prog core dump.What's wrong?Is it
all right on your machine or is it a bug?
open Printf
open Perl
let test ()=
try
let sv=Perl.eval "3+7" in
let r=int_of_sv sv in
printf "result=%i" r
with _->printf "error"
let ()=Thread.join (Thread.create test ())
The command line:
ocamlc -thread -I +perl /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a
perl4caml.cma unix.cma threads.cma test.ml -o test
Version:
Ocaml 3.08.3 & 3.09.0
perl4caml 0.9.3
regards.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] perl4caml crashed with threads
2005-11-14 2:16 perl4caml crashed with threads xuzq
@ 2005-11-14 10:09 ` Richard Jones
2005-11-14 10:02 ` Florian Weimer
2005-11-15 2:03 ` xuzq
0 siblings, 2 replies; 6+ messages in thread
From: Richard Jones @ 2005-11-14 10:09 UTC (permalink / raw)
To: xuzq; +Cc: caml-list
On Mon, Nov 14, 2005 at 02:16:43AM +0000, xuzq wrote:
> On my debian sid box,the following prog core dump.What's wrong?Is it
> all right on your machine or is it a bug?
This crashes on my machine too. However if you remove all references
to threads, then it works. libperl and perl4caml don't make any
attempt to be thread-safe.
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] perl4caml crashed with threads
2005-11-14 10:09 ` [Caml-list] " Richard Jones
@ 2005-11-14 10:02 ` Florian Weimer
2005-11-15 2:03 ` xuzq
1 sibling, 0 replies; 6+ messages in thread
From: Florian Weimer @ 2005-11-14 10:02 UTC (permalink / raw)
To: Richard Jones; +Cc: xuzq, caml-list
* Richard Jones:
> On Mon, Nov 14, 2005 at 02:16:43AM +0000, xuzq wrote:
>> On my debian sid box,the following prog core dump.What's wrong?Is it
>> all right on your machine or is it a bug?
>
> This crashes on my machine too. However if you remove all references
> to threads, then it works. libperl and perl4caml don't make any
> attempt to be thread-safe.
Debian's libperl does (it's compiled for thread safety), so perl4caml
is the likely culprit.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: perl4caml crashed with threads
2005-11-14 10:09 ` [Caml-list] " Richard Jones
2005-11-14 10:02 ` Florian Weimer
@ 2005-11-15 2:03 ` xuzq
2005-11-15 11:52 ` [Caml-list] " Richard Jones
1 sibling, 1 reply; 6+ messages in thread
From: xuzq @ 2005-11-15 2:03 UTC (permalink / raw)
To: caml-list
Richard Jones <rich <at> annexia.org> writes:
>
> On Mon, Nov 14, 2005 at 02:16:43AM +0000, xuzq wrote:
> > On my debian sid box,the following prog core dump.What's wrong?Is it
> > all right on your machine or is it a bug?
>
> This crashes on my machine too. However if you remove all references
> to threads, then it works. libperl and perl4caml don't make any
> attempt to be thread-safe.
>
> Rich.
>
Yes,it 's ok without threads and i see perl4caml may not be thread-safe.I 'm
only curious about why only "eval" crashes and "call" looks fine.In my program
another thread run the following code without any error.
let (sv_dbf_sz,sv_dbf_sh)=(call_class_method "CAM::DBF" "new" [sv_of_string
path_sz],call_class_method "CAM::DBF" "new" [sv_of_string path_sh]) in
let (rn_sz,rn_sh)=(int_of_sv (call_method sv_dbf_sz "nrecords" []),int_of_sv
(call_method sv_dbf_sh "nrecords" [])) in
for i=0 to rn_sz-1 do
let row = call_method_array sv_dbf_sz "fetchrow_array" [sv_of_int i] in
match row with
...
Thank you for your excellent perl4caml,Richard!Would it be possible for perl
to callocaml code just like the Inline::OCaml thoughts in that post:
http://caml.inria.fr/pub/ml-archives/caml-list/2002/02/
e363d76f1e9b94779b1ffe7de3a7c011.en.html?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Re: perl4caml crashed with threads
2005-11-15 2:03 ` xuzq
@ 2005-11-15 11:52 ` Richard Jones
0 siblings, 0 replies; 6+ messages in thread
From: Richard Jones @ 2005-11-15 11:52 UTC (permalink / raw)
To: xuzq; +Cc: caml-list
On Tue, Nov 15, 2005 at 02:03:20AM +0000, xuzq wrote:
> Yes,it 's ok without threads and i see perl4caml may not be
> thread-safe.I 'm only curious about why only "eval" crashes and
> "call" looks fine.In my program another thread run the following
> code without any error.
I'm guessing that 'call' works by luck.
I had a quick scan of the code and I can't see anything obviously
unsafe. Since I never release the OCaml lock in any of the C code,
surely the C calls are all serialised? It might also be that
perl4caml_init is being called twice (from two threads) which would
probably cause bad things to happen. A simple print statement should
diagnose whether this is the case.
To be honest, I'm not sure what the threading issues are when calling
external C libraries. I rarely even use threading in OCaml, and as
you probably guessed, I've never used it at all from perl4caml.
> Thank you for your excellent perl4caml,Richard!Would it be possible for perl
> to callocaml code just like the Inline::OCaml thoughts in that post:
> http://caml.inria.fr/pub/ml-archives/caml-list/2002/02/e363d76f1e9b94779b1ffe7de3a7c011.en.html?
Inline::OCaml would certainly be nice to have, but I don't have the
time, or possibly even the skills, to write it.
Rich.
--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* perl4caml crashed with threads
@ 2005-11-13 13:38 Xu Zuoqian
0 siblings, 0 replies; 6+ messages in thread
From: Xu Zuoqian @ 2005-11-13 13:38 UTC (permalink / raw)
To: caml-list
Hi,
On my debian sid box,the following prog core dump.What's wrong?Is it
all right on your machine or is it a bug?
open Printf
open Perl
let test ()=
try
let sv=Perl.eval "3+7" in
let r=int_of_sv sv in
printf "result=%i" r
with _->printf "error"
let ()=Thread.join (Thread.create test ())
The command line:
ocamlc -thread -I +perl /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a
perl4caml.cma unix.cma threads.cma test.ml -o test
Version:
Ocaml 3.08.3 & 3.09.0
perl4caml 0.9.3
regards.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-11-15 11:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-14 2:16 perl4caml crashed with threads xuzq
2005-11-14 10:09 ` [Caml-list] " Richard Jones
2005-11-14 10:02 ` Florian Weimer
2005-11-15 2:03 ` xuzq
2005-11-15 11:52 ` [Caml-list] " Richard Jones
-- strict thread matches above, loose matches on Subject: below --
2005-11-13 13:38 Xu Zuoqian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox