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

Report cycles when inferring linked lists #93

Open
GoogleCodeExporter opened this issue Mar 4, 2015 · 4 comments
Open

Report cycles when inferring linked lists #93

GoogleCodeExporter opened this issue Mar 4, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Run Celeriac on the attached file with the --linked-lists flag 

What is the expected output? What do you see instead?
Celeriac crashes with an out of memory exception when running the instrumented 
program.

This is caused by a cycle in the Person class. 

Original issue reported on code.google.com by [email protected] on 13 Apr 2013 at 12:32

Attachments:

@GoogleCodeExporter
Copy link
Author

Expected behavior here is to terminate when the cycle is completed?

And all this time I thought detecting cycles in a linked list was just an 
interview question. 

Original comment by [email protected] on 13 Apr 2013 at 2:46

@GoogleCodeExporter
Copy link
Author

Ha, I've never been asked that one before. 

For ring buffers, it would make sense to terminate when the cycle is complete. 
But I'm not sure if that's the case in general. Can you check what Chicory does?

Original comment by [email protected] on 13 Apr 2013 at 3:16

@GoogleCodeExporter
Copy link
Author

I can't get linked lists to work in Chicory. Filed a bug here: 
https://code.google.com/p/daikon/issues/detail?id=11

Original comment by [email protected] on 4 Jun 2013 at 11:25

@GoogleCodeExporter
Copy link
Author

Documented the failure in the user manual, so if this is fixed update that. 
It's not an enhancement.

The canonical solution is to use two trackers on the linked list, start them at 
the same point and iterate through the list, advance tracker A two elements at 
a time and advance tracker B one element at a time. Then compare if they refer 
to the same element (and not null), if they are then the list contains a cycle. 
If A ever gets to null then there is no cycle

Original comment by [email protected] on 14 Jun 2013 at 12:04

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant