Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[C++ VERIFICATION] Improved cpp new and delete #1648

Merged
merged 7 commits into from Feb 7, 2024

Conversation

XLiZHI
Copy link
Collaborator

@XLiZHI XLiZHI commented Feb 6, 2024

Fixed C++ dangling pointer checking.

Fixed C++ double delete.

Next PR todo: move the adjustment of cpp new and delete into symex.

still wait for #1644

@XLiZHI XLiZHI marked this pull request as draft February 6, 2024 14:15
Copy link
Contributor

@lucasccordeiro lucasccordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have two comments here.

CORE
main.cpp

^VERIFICATION SUCCESSFUL$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a memory leak in this program.

Can you please create another test case that enables --memory-leak-leak?

foo->Increment(); // Incrementing the value

foo->Execute(); // Executing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also create another test case that adds the delete to mark it as VERIFICATION SUCCESSFUL?

@XLiZHI XLiZHI marked this pull request as ready for review February 6, 2024 16:32
Copy link
Member

@fbrausse fbrausse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can unify both branches by casting *code2 to the common base class const code_expression_data &. Otherwise LGTM.

@XLiZHI
Copy link
Collaborator Author

XLiZHI commented Feb 7, 2024

You can unify both branches by casting *code2 to the common base class const code_expression_data &. Otherwise LGTM.

Hi @fbrausse,

Thanks for your advice, I tried this, but cmake complained about it.

const code_expression_data &deref_code = is_code_cpp_delete2t(code2)? to_code_cpp_delete2t(code2)
                                                                    : to_code_cpp_del_array2t(code2);

different types ‘code_cpp_delete2t’ and ‘code_cpp_del_array2t’. Or do we have a general type cast function?

@fbrausse
Copy link
Member

fbrausse commented Feb 7, 2024

const auto &code_expr = static_cast<const code_expression_data &>(*code2); should work.

@XLiZHI
Copy link
Collaborator Author

XLiZHI commented Feb 7, 2024

const auto &code_expr = static_cast<const code_expression_data &>(*code2);

Great, thanks

@lucasccordeiro lucasccordeiro merged commit 396a1c8 into esbmc:master Feb 7, 2024
8 of 9 checks passed
@lucasccordeiro
Copy link
Contributor

Thanks for submitting this PR, @XLiZHI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants