← 输入框|github.com|刷新
Skip to content

symbolics_11.py and symbolics_14.py produce invalid code #2469

Closed

Description

@certik

How to reproduce:

$ lpython symbolics_14.py --show-c
[...]
// Implementations
void mmrv(void* x, struct list_CPtr *_lpython_return_variable)
{
    struct list_CPtr l1;
    struct list_CPtr constname0;
    list_init_CPtr(&constname0, 1);
    constname0.data[0] = x;
    constname0.current_end_point = 1;
    list_deepcopy_CPtr(&constname0, &l1);

    list_deepcopy_CPtr(&l1, _lpython_return_variable);

}

The line constname0.data[0] = x; is incorrect, instead it should be basic_assign(constname0.data[0], x);.

The current code thus contains dangling points, so it might or might not segfault.

Activity

  1. added
    bug
    on Jan 31, 2024
  2. certik commented on Jan 31, 2024

    @certik
    ContributorAuthor

    Exactly the same problem is in symbolics_11.py:

    $ lpython symbolics_11.py --show-c
    [...]
    // Implementations
    void test_extraction_of_elements()
    {
        int64_t _ele1;
        int64_t _ele2;
        int64_t _ele3;
    ...
        constname0.data[0] = x;
        constname0.data[1] = stack0;
        constname0.data[2] = stack1;
        constname0.data[3] = stack2;
    ...
  3. changed the title [-]symbolics_14.py produces invalid code[/-] [+]symbolics_11.py and symbolics_14.py produce invalid code[/+] on Jan 31, 2024
  4. certik commented on Jan 31, 2024

    @certik
    ContributorAuthor

    To fix this, here is a reference code that does the right thing: #2465, so all we need to do now is to ensure the symbolic pass is generating the same ASR as symbolics_15 does.

    In particular, instead of a simple assignment, it needs to call basic_assign, and first it needs to initialize constname0.data[3] on heap, just like in symbolics_15.

  5. anutosh491 commented on Feb 8, 2024

    @anutosh491
    Collaborator

    Can be closed as the issue has been correctly fixed through #2465 & #2477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsymbolic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions