Hello Waldek,

Le mar. 27 déc. 2022 à 02:43, Waldek Hebisch
<de...@fricas.math.uni.wroc.pl> a écrit :
>
> On Wed, Dec 21, 2022 at 12:38:15PM +0100, Grégory Vanuxem wrote:
> > Hello Waldek, hello all,
[SNIPPET]

>> The base is done for me, but... The Julia library requires an
>> initialisation and I can't figure out how to initialize its environment at
>> startup, I always encounter a fatal error: ReadOnlyMemoryError

> I have never seen such a message.

Me too, and, difficult to debug in fact.

> >
> > See :
> > ============================================================
> > └─$ fricas -nosman -rl
> > Checking for foreign routines
> > FRICAS="/usr/local/lib/fricas/target/x86_64-linux-gnu"
> > spad-lib="/usr/local/lib/fricas/target/x86_64-linux-gnu/lib/libspad.so"
> > gmp-lib="/usr/local/lib/fricas/target/x86_64-linux-gnu/lib/gmp_wrap.so"
> > julia-lib="/usr/local/lib/fricas/target/x86_64-linux-gnu/lib/julia_wrap.so"
> > foreign routines found
> > openServer result -2
> >                        FriCAS Computer Algebra System
> >                          Version: FriCAS 2022-07-16
> >                   Timestamp: mer. 21 déc. 2022 10:35:13 CET
> >
> > (1) -> )lisp (init-julia-env)
>
> Big question is what 'init-julia-env' is doing.

It's a call to the julia 'jl_init' routine in libjulia.so. Julia has
its own interpreter, stack, GC etc. so its environment needs to be initialized.
In fact I wonder if SBCL and Julia are compatible and how to
circumvent this. I'll see.

See: https://docs.julialang.org/en/v1/manual/embedding/

(defun init-julia-env()
    (if (not *julia-initialized*)
        (progn
            (sb-alien:alien-funcall
                (sb-alien:extern-alien "jl_init" (sb-alien:function
sb-alien:void)))
            (setf *julia-initialized* t))))

> > Value = T
> > (1) -> )lisp (jl-dbl-function "exp" 1.0)
> >
> > Value = 2.718281828459045
> > (1) -> exp(1.0)
> > fatal: error thrown and no exception handler available.
> > ReadOnlyMemoryError()
> > unknown function (ip: 0x52f7062f)
> <snip>
> > This is because above I begin by initializing Julia's env. So I can't even
> > build FriCAS if I automatize at startup the Julia's env.
> >
> > But, apparently, and I don't even know if I am in the right thinking
> > direction, if I "play" with different FriCAS's domains this does not
> > happen. Sometimes in fact.
>
> If you think that problem is related. would suggest trying:
>
> )set messages autoload on

Good idea, I didn't think about that. I'll give it a try. This is for
sure related but not only I think.
That's relatively difficult because of possible memory corruption
behind the scene.

For now to test my spad code FriCAS is initialized via .fricasrc with:
)set mess type off
sqrt 2;sqrt 2.0;x^3=7;x^3+7;
)set mess type on
--)lisp (init-julia-env)

But for example it's totally impossible to compile a .spad file if
Julia is initialized so I have to work around that to compile my spad
code i.e. use FriCAS with uninitialized Julia.
__
Greg


>
> --
>                               Waldek Hebisch
>
> --
> You received this message because you are subscribed to the Google Groups 
> "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to fricas-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/fricas-devel/20221227022657.ypgx275453f43ai5%40fricas.math.uni.wroc.pl.

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAHnU2dY98tXyA%3DNCHWQjz0Ye4SCbrzr3N9c%3DVJvG98Bx5uiVYA%40mail.gmail.com.

Reply via email to