IntersectMBO / cardano-node

The core component that is used to participate in a Cardano decentralised blockchain.
https://cardano.org
Apache License 2.0
3.06k stars 718 forks source link

[BUG] - Several potential bugs found using an automated code analysis tool #5926

Open zmandel opened 2 months ago

zmandel commented 2 months ago

Internal/External External

Area Other

Summary I ran a novel AI-based code-analysis tool on the entire cardano node directory (I'm the tool maker, its not released yet) and found 14 potential issues.

Steps to reproduce I didn't want to create an issue for each. The issue list is in this Google Sheet. I also uploaded it as issues cardano-node.csv but the CSV could be outdated as the Google Sheet is editable.

Scan Date: 7/27/2024 Scanned code: https://github.com/IntersectMBO/cardano-node/tree/1e6f75101b5a637169efd8cb29026ad23ba4a427/cardano-node/src/Cardano/Node

If this feedback is useful, I can gladly run the tool on other directories, even on the entire repository.

kevinhammond commented 2 months ago

Thank you!

erikd commented 2 months ago

One comment from our internal Slack channel that may be of interest to you:

I can’t comment on other items, as I have not looked at them, but item 4 seems bogus, unfortunately: The AI didn’t recognize bracket.

zmandel commented 2 months ago

indeed, the AI initially gave me 30 potential issues and I manually removed the bogus ones, I didn't notice that one (im new to haskell)

On Wed, Jul 31, 2024, 10:36 PM Erik de Castro Lopo @.***> wrote:

One comment from our internal Slack channel that may be of interest to you:

I can’t comment on other items, as I have not looked at them, but item 4 seems bogus, unfortunately: The AI didn’t recognize bracket.

— Reply to this email directly, view it on GitHub https://github.com/IntersectMBO/cardano-node/issues/5926#issuecomment-2261896933, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBJ2JZ2H5DCCSSN74MHMLLZPGUKTAVCNFSM6AAAAABLSFFSY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRRHA4TMOJTGM . You are receiving this because you authored the thread.Message ID: @.***>

erikd commented 2 months ago

The bracket family of functions in Haskell are of the form:

bracket setup shutdown action

Where the bracket function runs setup , then action and then shutdown (regardless of whether action threw an exception). Ie, shutdown is always run.

zmandel commented 2 months ago

@erikd @kevinhammond ahh, It seems you have confused the meaning of the last column "More Details" on that issue in line number 4. That code that uses "bracket" is actually the suggestion that my AI came up with. The actual Cardano code does not use a bracket and leaks the handle. I also updated the file and line number where it occurs (it was on shutdown.hs)

coot commented 1 month ago

For the network related things:

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.