frenetic-lang / pyretic

The Pyretic language and runtime system
http://frenetic-lang.org/pyretic/
159 stars 99 forks source link

util.frozendict issues #5

Closed joshreich closed 11 years ago

joshreich commented 11 years ago

hash function doesn't appear to hash consistently (frozendicts with identical entries hash to different values) equality operators use those provided by the dict class - I recall Chris saying that these were incorrectly implemented in python. If so, these need to be fixed.

monsanto commented 11 years ago

I remember finding a bug similar to this, yes. After reviewing the Python reference, I could only conclude that there was a bug in Python. Is this affecting us again? If so, where in the code?

reitblatt commented 11 years ago

Do you have a concrete example of two frozendict's not returning the same hash value?

On Thu, Jan 10, 2013 at 11:54 AM, Christopher Monsanto < notifications@github.com> wrote:

I remember finding a bug similar to this, yes. After reviewing the Python reference, I could only conclude that there was a bug in Python. Is this affecting us again? If so, where in the code?

— Reply to this email directly or view it on GitHubhttps://github.com/frenetic-lang/pyretic/issues/5#issuecomment-12106497.

joshreich commented 11 years ago

Mark- I'll send a concrete example later today. Chris- I don't think it is currently effecting us, although that's in part bc I've opted not to use that functionality. On Jan 10, 2013, at 12:26 PM, Mark Reitblatt notifications@github.com wrote:

Do you have a concrete example of two frozendict's not returning the same hash value?

On Thu, Jan 10, 2013 at 11:54 AM, Christopher Monsanto < notifications@github.com> wrote:

I remember finding a bug similar to this, yes. After reviewing the Python reference, I could only conclude that there was a bug in Python. Is this affecting us again? If so, where in the code?

— Reply to this email directly or view it on GitHubhttps://github.com/frenetic-lang/pyretic/issues/5#issuecomment-12106497.

— Reply to this email directly or view it on GitHub.

monsanto commented 11 years ago

@reitblatt I wish I saved that example, but I didn't. This wouldn't be the first bug I've found in Python: http://bugs.python.org/issue9226

joshreich commented 11 years ago

Hi Mark,

Sorry this took me a bit.
I've pushed a new branch to the repo named bugtest. If you pull this branch and run in two separate windows $ ./pyretic/mininet.sh --switch ovsk $ pox.py --no-cli pyretic/examples/learning_switch.py then do a pingall in the first, you will see the hashing issue.

If you then go reverse the commenting shown below, and re-run, you'll see the hashing works (the way I expect it to).

match(Predicate): def hash(self): return hash(self.map)

return hash(repr(self))

Thanks, -Josh

On Jan 10, 2013, at 12:26 PM, Mark Reitblatt notifications@github.com wrote:

Do you have a concrete example of two frozendict's not returning the same hash value?

On Thu, Jan 10, 2013 at 11:54 AM, Christopher Monsanto < notifications@github.com> wrote:

I remember finding a bug similar to this, yes. After reviewing the Python reference, I could only conclude that there was a bug in Python. Is this affecting us again? If so, where in the code?

— Reply to this email directly or view it on GitHubhttps://github.com/frenetic-lang/pyretic/issues/5#issuecomment-12106497.

— Reply to this email directly or view it on GitHub.

monsanto commented 11 years ago

The problem was that the objects in the map did not in fact hash the same. The latest master branch should fix this.

joshreich commented 11 years ago

Thanks for pushing the fix to this! From the log details it appears the fundamental problem was that the Exact class hadn't been given a hash method which was filtering its way up - makes sense.

On Jan 17, 2013, at 4:02 AM, Christopher Monsanto notifications@github.com wrote:

The problem was that the objects in the map did not in fact hash the same.

— Reply to this email directly or view it on GitHub.