strange behaviour...

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
gratefulfrog
Posts: 149
Joined: Sun Mar 01, 2015 12:10 pm

Re: strange behaviour...

Post by gratefulfrog » Thu Sep 01, 2016 1:04 pm

Well, I would normally jut seek a workaround too, but this time understanding the bug took so much effort that once I had done all that, I felt that I owed it to the community to help to fix it...

Although, perhaps it is not a bug in micropython, but in my code...

But to support the bug hypothesis, it seems to me that python semantics are such that: if a == b then f(a) == f(b), but maybe I am wrong on that point?

In my case, I had
x==y
but
dictionary[x] != dictionary[y]
even worse, dictionary[x] returned a correct result but dictionary[y] raised an exception!

Anyway, we'll see what comes of it... Now off to eat lunch after 6 hours of debugging...
Ciao,
B

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: strange behaviour...

Post by pythoncoder » Thu Sep 01, 2016 1:20 pm

I agree you've found a bug. I just doubt that the busy dev team will have time to examine such a complex test case. It's generally up to the discoverer of the bug to produce a small reproducible test case. But it's possible that Damien or Paul might have a flash of insight...
Peter Hinch
Index to my micropython libraries.

Damien
Site Admin
Posts: 647
Joined: Mon Dec 09, 2013 5:02 pm

Re: strange behaviour...

Post by Damien » Fri Sep 02, 2016 10:15 am

Thanks Bob for the really great effort finding and putting together this bug report! It was a very important one to fix. For example, someone might use frozen bytecode to create a product which sits out in the field, and this bug might have only showed itself after months of the device running without issue. Such things would be almost impossible to find and fix in the field.

gratefulfrog
Posts: 149
Joined: Sun Mar 01, 2015 12:10 pm

Re: strange behaviour...

Post by gratefulfrog » Fri Sep 02, 2016 11:06 am

Hi Damien!

It is my pleasure to help in any way! And you're right, this bug could have shown up at any time and was excruciatingly hard to find, for me anyway, because of so many interacting elements: worked fine on linux, worked fine from ram or from flash but only when combing them would it show up... and the code I was running was complex, interrupt driven, and reading and writing to the SD card, but the card could not be consulted from the linux pc without unmounting the pyboard first... lots of things to fight with, and it never even occurred to me that the bug could be in micropython itself - I always assume that my code is wrong unless I can definitely say it is not - which is nearly never...

Anyway, you fixed it and the world is a better place! Thanks again!

I hope you and your family are well and we can meet again sometime!

Ciao!
B

Post Reply