fix issue #I6E6LZ: scf crash when analysize multi-return-values function.
authoryu.dongliang <18588496441@163.com>
Fri, 10 Feb 2023 04:01:59 +0000 (12:01 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 10 Feb 2023 04:02:04 +0000 (12:02 +0800)
core/scf_dag.c
parse/scf_dfa_container.c
parse/scf_dfa_type.c

index 0c6cbdba11e26a6dd6e0e7ecf4a6175119056f1b..7e7b44d2c4e4513d93cec9d36568c306345548b9 100644 (file)
@@ -319,7 +319,7 @@ scf_dag_node_t* scf_dag_node_alloc(int type, scf_variable_t* var, const scf_node
        if (SCF_OP_CALL == type) {
                scf_logw("dag_node: %#lx, dag_node->type: %d", 0xffff & (uintptr_t)dag_node, dag_node->type);
                if (var) {
-                       printf(", var: %p, var->type: %d", var, var->type);
+                       printf(", var: %#lx, var->type: %d", 0xffff & (uintptr_t)var, var->type);
                        if (var->w)
                                printf(", v_%d_%d/%s", var->w->line, var->w->pos, var->w->text->data);
                        else {
@@ -496,11 +496,19 @@ int scf_dag_node_same(scf_dag_node_t* dag_node, const scf_node_t* node)
 {
        int i;
 
+       const scf_node_t* split = NULL;
+
        if (node->split_flag) {
 
                if (dag_node->var != _scf_operand_get(node))
                        return 0;
-               node = node->split_parent;
+
+               split = node;
+               node  = node->split_parent;
+
+               scf_logd("split type: %d, node: %#lx, var: %#lx\n", split->type,    0xffff & (uintptr_t)split,    0xffff & (uintptr_t)split->var);
+               scf_logd("node  type: %d, node: %#lx, var: %#lx\n", node->type,     0xffff & (uintptr_t)node,     0xffff & (uintptr_t)node->var);
+               scf_logd("dag   type: %d, node: %#lx, var: %#lx\n", dag_node->type, 0xffff & (uintptr_t)dag_node, 0xffff & (uintptr_t)dag_node->var);
        }
 
        if (dag_node->type != node->type)
@@ -636,6 +644,9 @@ cmp_childs:
                scf_variable_t* v0 = _scf_operand_get(node);
                scf_variable_t* v1 = dag_node->var;
 
+               if (split)
+                       v0 = _scf_operand_get(split);
+
                if (v0 && v0->w && v1 && v1->w) {
                        if (v0->type != v1->type) {
                                scf_loge("v0: %d/%s_%#lx, split_flag: %d\n", v0->w->line, v0->w->text->data, 0xffff & (uintptr_t)v0, node->split_flag);
index cc791e6d7a464110456a10a42d084ffbc747aa4f..cc8d6c7b15cf721cca0eb7f3c3a567e160f2374f 100644 (file)
@@ -83,6 +83,9 @@ static int _container_action_comma(scf_dfa_t* dfa, scf_vector_t* words, void* da
        scf_stack_t*          s     = d->module_datas[dfa_module_container.index];
        dfa_container_data_t* cd    = scf_stack_top(s);
 
+       if (!cd)
+               return SCF_DFA_NEXT_SYNTAX;
+
        if (0 == cd->container->nb_nodes) {
                if (!d->expr) {
                        scf_loge("\n");
index 62e5f4c0c04105ef4e74602eb86b5f0e6b59fbf6..ba4804d881571b811b792d43c0b426d556afbcf4 100644 (file)
@@ -309,7 +309,7 @@ static int _dfa_init_syntax_type(scf_dfa_t* dfa)
        for (i = 0; i < base_type->childs->size; i++) {
                scf_dfa_node_t* n = base_type->childs->data[i];
 
-               scf_logi("n->name: %s\n", n->name);
+               scf_logw("n->name: %s\n", n->name);
        }
 
        scf_logi("\n");