Skip to content

Conversation

@aaaaalbert
Copy link
Contributor

The uniqueid module had a bug when "imported" with the RepyV1
preprocessor, repypp. (That program had no notion of modules already
imported, so it would paste multiple copies of imported libraries
and thus cause duplicate IDs with the uniqueid module). This bug
was patched for V1, but the patch never removed since.

In RepyV2, dylink is used to import modules, and it does a much
better job at importing modules only once, see for instance
#55. Therefore, we can remove the old
patch!

To verify that removing the patch is safe, I also added a unit test
that checks uniqueid's

  • basic functionality,
  • functioning after reimport, and
  • function across threads.

The `uniqueid` module had a bug when "imported" with the RepyV1
preprocessor, `repypp`. (That program had no notion of modules already
imported, so it would paste multiple copies of imported libraries
and thus cause duplicate IDs with the `uniqueid` module). This bug
was patched for V1, but the patch never removed since.

In RepyV2, `dylink` is used to import modules, and it does a much
better job at importing modules only once, see for instance
SeattleTestbed#55. Therefore, we can remove the old
patch!

To verify that removing the patch is safe, I also added a unit test
that checks `uniqueid`'s
* basic functionality,
* functioning after reimport, and
* function across threads.

current_time = getruntime()
uniqueid_idlist = [int((current_time - int(current_time)) * 2**32)]
uniqueid_idlist = [0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why exactly does this have to be a list? It will always only hold one element, right?


uniqueid2 = dy_import_module("uniqueid.r2py")

assert uniqueid2.uniqueid_getid() != uniqueid.uniqueid_getid(), "Got the same ID twice after pseudo-reimporting!"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also verify that uniqueid2 does not return an id that was already returned by uniqueid, i.e.
assert uniqueid2.uniqueid_getid() not in oldids to catch the case that the new import resets the module store.

sleep(5)

for anid in idlist:
assert idlist.count(anid)==1, "Duplicate ID: " + str(anid)
Copy link
Contributor

Choose a reason for hiding this comment

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

idlist.count(anid) == 1 (whitespaces)

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.

2 participants