Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make LeanDefinitionalEngine::new() thread safe #227

Open
3 tasks done
khieta opened this issue Feb 21, 2024 · 1 comment
Open
3 tasks done

Make LeanDefinitionalEngine::new() thread safe #227

khieta opened this issue Feb 21, 2024 · 1 comment
Assignees

Comments

@khieta
Copy link
Contributor

khieta commented Feb 21, 2024

Before opening, please confirm:

Bug Category

Other

Describe the bug

If I try to run multiple #[test]s that use the Lean engine (created via LeanDefinitionalEngine::new()), then I get a (signal: 11, SIGSEGV: invalid memory reference) failure. If I run with the --test-threads=1 option it looks like the first test succeeds, but the next one fails.

Expected behavior

No reponse

Reproduction steps

To observe this behavior, make a second copy of the integration_tests_on_def_impl() test and run cargo test.

Code Snippet

No response

Log output

No response

Additional configuration

No response

Operating System

AL2

Additional information and screenshots

No response

@khieta khieta added bug Something isn't working backlog labels Feb 21, 2024
@andrewmwells-amazon andrewmwells-amazon removed the bug Something isn't working label Mar 4, 2024
@andrewmwells-amazon
Copy link
Contributor

Removing the "bug" label since this is expected behavior IIUC. integration_tests_on_def_impl() calls LeanDefinitionalEngine::new() which is implemented as:

pub fn new() -> Self {
        if env::var("RUST_LEAN_INTERFACE_INIT").is_err() {
            unsafe { lean_initialize_runtime_module() };
            unsafe { lean_initialize() };
            unsafe { initialize_DiffTest_Main(1, lean_io_mk_world()) };
            unsafe { lean_io_mark_end_initialization() };
            env::set_var("RUST_LEAN_INTERFACE_INIT", "1");
        }
        Self {}
    }

https://github.com/digama0/lean-sys/blob/main/src/init.rs#L6 notes that lean_initialize_runtime_module and lean_initialize are not thread safe.

Keeping the issue open as we should switch to the thread-safe calls if possible.

@andrewmwells-amazon andrewmwells-amazon self-assigned this Mar 4, 2024
@andrewmwells-amazon andrewmwells-amazon changed the title Issue running Lean in tests Make LeanDefinitionalEngine::new() thread safe Mar 4, 2024
andrewmwells-amazon added a commit that referenced this issue Jun 20, 2024
Signed-off-by: Andrew Wells <anmwells@amazon.com>
andrewmwells-amazon added a commit that referenced this issue Jun 20, 2024
Signed-off-by: Andrew Wells <anmwells@amazon.com>
andrewmwells-amazon added a commit that referenced this issue Jun 20, 2024
Signed-off-by: Andrew Wells <anmwells@amazon.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants