I use JNI with multiple "Environment" clips, and I "run" each environment in different java thread.
Sometimes the library doesnt support this concurrency. Sometimes it work, but the most of time the JVM crash just after clips "random" errors.
Can you help me with this problem ?
Here are some examples of error logs from clips. These five examples occurs randomly when running in parallel two thread who run two different clips Environement. If I run these two thread one after the other no error occur.
I also give you one of the log of the JVM crash in attachment.
Exemple1 :
FIRE 32 init_detecte: f-0
==> Activation 0 detecte_1ere_rente_v: f-17,f-33,f-18,[requeran],,,[bases_p],,,,,,,,,
==> Activation 0 detecte_1ere_rente_v: f-17,f-33,f-18,[conjoint],,,[bases_p2],,,,,,,,, [[INSFUNARGACCES23] ] No such instance Function get-date_decesRtnLong in function received a request from function instance-addressstr-cat.
for argument #[2PRCCODE which is non-existent
6[] ARGACCESThis error occurred while evaluating arguments for the 3message] Function get-date_decesRtnLong.
received a request from function [�PRCCODE for argument #63] which is non-existent
This error occurred while evaluating arguments [for the ARGACCES3deffunction] Function extrait_annee_moisRtnLong.
received a request from function extrait_annee_mois for argument #4 which is non-existent
Exemple2 :
FIRE 43 mut_1ere_rente_v: f-41,f-17,[bases_p2],[gen80],[glob],[conjoint]
==> Activation 0 detecte_1ere_rente_v: f-44,f-33,f-18,[requeran],,,[bases_p],,,,,,,,,*
==> Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
==> Activation 10000 determine_type_calcul: [b2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
<== Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
<== Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint] [ARGACCES6] Function RtnLong received a request from function if for argument #2 which is not of type number [[ARGACCESPRCCODE34] ] Function Execution halted during the actions of RtnLongmessage-handler received a request from function (get-progn$-index)nettoie_ci for argument # primary3 in class which is non-existent
COTISANT
ARGACCES3[Function PRCCODERtnLong4 received a request from function ] sendExecution halted during the actions of for argument #message-handler 4analyse1_ci which is non-existent
primary in class COTISANT [PRCCODE4] Execution halted during the actions of message-handler analyse_ci_princ primary in class MAIN::COTISANT [PRCCODE4] Execution halted during the actions of defrule mut_1ere_rente_v.
Exemple3 :
FIRE 47 mut_1ere_rente_v: f-44,f-17,[bases_p],[gen63],[glob],[requeran]
==> Activation 0 detecte_1ere_rente_v: f-47,f-35,f-18,[conjoint],,,[bases_p2],,,,,,,,,*
==> Activation 10000 determine_type_calcul: [copie_bases],[requeran]
==> Activation 10000 determine_type_calcul: [b1],[requeran]
==> Activation 10000 determine_type_calcul: [bases_p],[requeran]
<== Activation 10000 determine_type_calcul: [copie_bases],[requeran]
<== Activation 10000 determine_type_calcul: [bases_p],[requeran]
==> Activation 10000 determine_type_calcul: [bases_p],[requeran] [ARGACCES6] Function RtnLexeme received a request from function e for argument #1 which is not of type symbol, string, or instance name [ARGACCES[6ARGACCES] 5Function ] RtnLongFunction received a request from function <=send expected argument # for argument #22 to be of type which is not of type integer or floatnumber
[PRCCODE4] Execution halted during the actions of defrule compte_mois_ci.
Exemple4 :
FIRE 43 mut_1ere_rente_v: f-41,f-17,[bases_p2],[gen80],[glob],[conjoint]
==> Activation 0 detecte_1ere_rente_v: f-44,f-33,f-18,[requeran],,,[bases_p],,,,,,,,,*
==> Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
==> Activation 10000 determine_type_calcul: [b2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
<== Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
<== Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint] [ARGACCES3] Function RtnLexeme received a request from function delete-instance for argument #1 which is non-existent [ARGACCES6] Function RtnLong received a request from function estmcot for argument #3 which is not of type number [ARGACCES6] Function RtnLong received a request from function estmcot for argument #4 which is not of type number [PRCCODE4] Execution halted during the actions of message-handler an_dom_etr-69_10 primary in class CPTIND [PRCCODE4] Execution halted during the actions of message-handler ci_annee primary in class CPTIND [PRCCODE4] Execution halted during the actions of message-handler analyse1_ci primary in class COTISANT [PRCCODE4] Execution halted during the actions of message-handler analyse_ci_princ primary in class MAIN::COTISANT [PRCCODE4] Execution halted during the actions of defrule mut_1ere_rente_v.
Exemple5 :
FIRE 41 duplique_obj_prescription: f-39,[gen78],* [ARGACCES3] Function RtnLexeme received a request from function (direct-duplicate) for argument #1 which is non-existent [ARGACCES[6PRCCODE] 4Function ] RtnLongExecution halted during the actions of defrule received a request from function duplique_obj_prescriptionduplicate-instance.
for argument #2 which is not of type number
It seems that I am able to solve a part of my problem. I used the deprecated "UserFunctions" in "userfonctions.c" and it has no "environment" pointer. I made some modifications to use "EnvUserFunction". It works much better.
I still get time to time errors with Environment concurrency. It seems that these errors occurs sometimes when I have this kind of code (I know that the ?insname is useless in the example below) :
(bind ?insname (symbol-to-instance-name (gensym)))
(make-instance ?insname of PASSE_VAR ....
If I replace this code by
(make-instance of PASSE_VAR ....
I never have problems
Do I miss something ? Is the (gensym) shared for all Environement ? Should I use (gensym*) ?
Last edit: Chaubert Jérôme 2016-07-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The gensym function uses the functionalty described in section 9.3, Allocating Environment Data, of the Advanced Programming Guide to maintain the generated symbols separately for each environment. In fact, all of the CLIPS code uses this functionality to maintain the data structures for each environment so that nothing is shared between environments.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use JNI with multiple "Environment" clips, and I "run" each environment in different java thread.
Sometimes the library doesnt support this concurrency. Sometimes it work, but the most of time the JVM crash just after clips "random" errors.
Can you help me with this problem ?
Here are some examples of error logs from clips. These five examples occurs randomly when running in parallel two thread who run two different clips Environement. If I run these two thread one after the other no error occur.
I also give you one of the log of the JVM crash in attachment.
Exemple1 :
FIRE 32 init_detecte: f-0
==> Activation 0 detecte_1ere_rente_v: f-17,f-33,f-18,[requeran],,,[bases_p],,,,,,,,,
==> Activation 0 detecte_1ere_rente_v: f-17,f-33,f-18,[conjoint],,,[bases_p2],,,,,,,,,
[[INSFUNARGACCES23] ] No such instance Function get-date_decesRtnLong in function received a request from function instance-addressstr-cat.
for argument #[2PRCCODE which is non-existent
6[] ARGACCESThis error occurred while evaluating arguments for the 3message] Function get-date_decesRtnLong.
received a request from function [�PRCCODE for argument #63] which is non-existent
This error occurred while evaluating arguments [for the ARGACCES3deffunction] Function extrait_annee_moisRtnLong.
received a request from function extrait_annee_mois for argument #4 which is non-existent
Exemple2 :
FIRE 43 mut_1ere_rente_v: f-41,f-17,[bases_p2],[gen80],[glob],[conjoint]
==> Activation 0 detecte_1ere_rente_v: f-44,f-33,f-18,[requeran],,,[bases_p],,,,,,,,,*
==> Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
==> Activation 10000 determine_type_calcul: [b2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
<== Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
<== Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
[ARGACCES6] Function RtnLong received a request from function if for argument #2 which is not of type number
[[ARGACCESPRCCODE34] ] Function Execution halted during the actions of RtnLongmessage-handler received a request from function (get-progn$-index)nettoie_ci for argument # primary3 in class which is non-existent
COTISANT
ARGACCES3 [Function PRCCODERtnLong4 received a request from function ] sendExecution halted during the actions of for argument #message-handler 4analyse1_ci which is non-existent
primary in class COTISANT
[PRCCODE4] Execution halted during the actions of message-handler analyse_ci_princ primary in class MAIN::COTISANT
[PRCCODE4] Execution halted during the actions of defrule mut_1ere_rente_v.
Exemple3 :
FIRE 47 mut_1ere_rente_v: f-44,f-17,[bases_p],[gen63],[glob],[requeran]
==> Activation 0 detecte_1ere_rente_v: f-47,f-35,f-18,[conjoint],,,[bases_p2],,,,,,,,,*
==> Activation 10000 determine_type_calcul: [copie_bases],[requeran]
==> Activation 10000 determine_type_calcul: [b1],[requeran]
==> Activation 10000 determine_type_calcul: [bases_p],[requeran]
<== Activation 10000 determine_type_calcul: [copie_bases],[requeran]
<== Activation 10000 determine_type_calcul: [bases_p],[requeran]
==> Activation 10000 determine_type_calcul: [bases_p],[requeran]
[ARGACCES6] Function RtnLexeme received a request from function e for argument #1 which is not of type symbol, string, or instance name
[ARGACCES[6ARGACCES] 5Function ] RtnLongFunction received a request from function <=send expected argument # for argument #22 to be of type which is not of type integer or floatnumber
[PRCCODE4] Execution halted during the actions of defrule compte_mois_ci.
Exemple4 :
FIRE 43 mut_1ere_rente_v: f-41,f-17,[bases_p2],[gen80],[glob],[conjoint]
==> Activation 0 detecte_1ere_rente_v: f-44,f-33,f-18,[requeran],,,[bases_p],,,,,,,,,*
==> Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
==> Activation 10000 determine_type_calcul: [b2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
<== Activation 10000 determine_type_calcul: [copie_bases],[conjoint]
<== Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
==> Activation 10000 determine_type_calcul: [bases_p2],[conjoint]
[ARGACCES3] Function RtnLexeme received a request from function delete-instance for argument #1 which is non-existent
[ARGACCES6] Function RtnLong received a request from function estmcot for argument #3 which is not of type number
[ARGACCES6] Function RtnLong received a request from function estmcot for argument #4 which is not of type number
[PRCCODE4] Execution halted during the actions of message-handler an_dom_etr-69_10 primary in class CPTIND
[PRCCODE4] Execution halted during the actions of message-handler ci_annee primary in class CPTIND
[PRCCODE4] Execution halted during the actions of message-handler analyse1_ci primary in class COTISANT
[PRCCODE4] Execution halted during the actions of message-handler analyse_ci_princ primary in class MAIN::COTISANT
[PRCCODE4] Execution halted during the actions of defrule mut_1ere_rente_v.
Exemple5 :
FIRE 41 duplique_obj_prescription: f-39,[gen78],*
[ARGACCES3] Function RtnLexeme received a request from function (direct-duplicate) for argument #1 which is non-existent
[ARGACCES[6PRCCODE] 4Function ] RtnLongExecution halted during the actions of defrule received a request from function duplique_obj_prescriptionduplicate-instance.
for argument #2 which is not of type number
Last edit: Chaubert Jérôme 2016-07-07
It seems that I am able to solve a part of my problem. I used the deprecated "UserFunctions" in "userfonctions.c" and it has no "environment" pointer. I made some modifications to use "EnvUserFunction". It works much better.
I still get time to time errors with Environment concurrency. It seems that these errors occurs sometimes when I have this kind of code (I know that the ?insname is useless in the example below) :
If I replace this code by
(make-instance of PASSE_VAR ....
I never have problems
Do I miss something ? Is the (gensym) shared for all Environement ? Should I use (gensym*) ?
Last edit: Chaubert Jérôme 2016-07-07
The gensym function uses the functionalty described in section 9.3, Allocating Environment Data, of the Advanced Programming Guide to maintain the generated symbols separately for each environment. In fact, all of the CLIPS code uses this functionality to maintain the data structures for each environment so that nothing is shared between environments.