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

"watch""check" return nothing #199

Open
PorcoRosso85 opened this issue Mar 2, 2023 · 6 comments
Open

"watch""check" return nothing #199

PorcoRosso85 opened this issue Mar 2, 2023 · 6 comments

Comments

@PorcoRosso85
Copy link

PorcoRosso85 commented Mar 2, 2023

スクリーンショット 2023-03-02 12 54 54

Excuse me.
Let me know why crosshair check return nothing?

Example codes are from:
https://crosshair.readthedocs.io/en/latest/kinds_of_contracts.html
https://crosshair.readthedocs.io/en/latest/contracts.html

these codes should return breaking contract, I think,,,

@PorcoRosso85
Copy link
Author

update...

https://github.com/pschanely/CrossHair/tree/main/crosshair/examples/PEP316/bugs_detected
I'll check here. If I wander, I'll ask again.

@PorcoRosso85
Copy link
Author

If there is way to check or debug why it returns nothing, let me know how .

@pschanely
Copy link
Owner

Sorry - I'm not sure whether I understand; did you already resolve your issue, or no? A few quick notes from your screenshot:

  1. in the postcondition, return should be written __return__
  2. supplying --analysis_kind=asserts will cause crosshair to ignore PEP316 contracts; so, you'd only be checking the function with the leading assert at the top in that case.

At any rate, if you haven't already solved the problems, maybe paste the code directly here so that I can reproduce; and/or try it at crosshair-web.org and make a Gist to send me. (this function that you're attempting reports an error, for example)

If there is way to check or debug why it returns nothing, let me know how.

CrossHair should better features for this - sorry.

  1. To ensure it even detects your conditions, try running check with --report_all: this will report the lines on which it detects a condition to check. (so if you STILL get no output, crosshair isn't even attempting to check anything at all)
  2. You can try running with -v for verbose. This will be VERY verbose, and likely not useful for an end user, unfortunately.

@PorcoRosso85
Copy link
Author

PorcoRosso85 commented Mar 2, 2023

Thanks for your kind.
Excuse my English, I've not resolve the issue yet.

what I tried on playground
https://crosshair-web.org/?crosshair=0.1&python=3.8&gist=c0ac20f2122d51c7e5a1be6459d40588

then, I tried same code on my local env, target file path ./288/crosshair.py
スクリーンショット 2023-03-03 7 54 46

crosshair seems not to check

> crosshair check --report_all 288/crosshair.py
> crosshair check -v 288/crosshair.py
169170.962| |unwalled_main() CrossHair v0.0.37 on linux, Python 3.10.8
169170.964| |unwalled_main() Installed plugins: []
169170.966|  |check() Check  crosshair
169170.970|      |analyze_function() Analyzing  env_info
169170.987|       |condition_parser() Using parsers:  (AnalysisKind.PEP316, AnalysisKind.icontract, AnalysisKind.deal)
> crosshair watch -v 288/crosshair.py
169350.218|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169351.226|    |run_iteration() Worker pool tasks complete
169351.328|    |run_iteration() starting pass with a condition timeout of 2097152.0
169351.328|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169352.349|    |run_iteration() Worker pool tasks complete
169352.450|    |run_iteration() starting pass with a condition timeout of 4194304.0
169352.450|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169353.491|    |run_iteration() Worker pool tasks complete
169353.591|    |run_iteration() starting pass with a condition timeout of 8388608.0
169353.591|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169354.539|    |run_iteration() Worker pool tasks complete
169354.640|    |run_iteration() starting pass with a condition timeout of 16777216.0
169354.641|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169355.651|    |run_iteration() Worker pool tasks complete
169355.752|    |run_iteration() starting pass with a condition timeout of 33554432.0
169355.752|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169356.796|    |run_iteration() Worker pool tasks complete
169356.898|    |run_iteration() starting pass with a condition timeout of 67108864.0
169356.898|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169357.827|    |run_iteration() Worker pool tasks complete
169357.928|    |run_iteration() starting pass with a condition timeout of 134217728.0
169357.929|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169358.887|    |run_iteration() Worker pool tasks complete
169358.988|    |run_iteration() starting pass with a condition timeout of 268435456.0
169358.988|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169359.956|    |run_iteration() Worker pool tasks complete
169360.056|    |run_iteration() starting pass with a condition timeout of 536870912.0
169360.057|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])
169361.005|    |run_iteration() Worker pool tasks complete
169361.106|    |run_iteration() starting pass with a condition timeout of 1073741824.0
169361.107|    |run_iteration() Files: dict_keys([PosixPath('288/crosshair.py')])

@pschanely
Copy link
Owner

OH! You caught an interesting kind of bug. Essentially, crosshair needs to import your code a module under some name; in your case that module will be named "crosshair" which conflicts with crosshair itself. (the same problem would happen for files named like standard library modules, e.g. "sys.py", "typing.py", etc)

For now, you can either rename "crosshair.py" to something else, or create an empty __init__.py file next to it (in which case it will be loaded as the module "288.crosshair" which won't conflict).

Assuming my diagnosis is correct (please confirm), I'd like to repurpose this issue to ensure crosshair reports an error in cases like these.

@pschanely pschanely reopened this Mar 3, 2023
@PorcoRosso85
Copy link
Author

Solved!
If this helps you, I think it was joy for me to ask you.

Maybe this your answer will solve #198

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

No branches or pull requests

2 participants