-
Notifications
You must be signed in to change notification settings - Fork 25.5k
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
fix(core): error due to integer overflow when there are too many host bindings #38014
fix(core): error due to integer overflow when there are too many host bindings #38014
Conversation
… bindings We currently use 16 bits to store information about nodes in a view. The 16 bits give us 65536 entries in the array, but the problem is that while the number is large, it can be reached by ~4300 directive instances with host bindings which could realistically happen is a very large view, as seen in angular#37876. Once we hit the limit, we end up overflowing which eventually leads to a runtime error. These changes bump to using 20 bits which gives us around 1048576 entries in the array or 16 times more than the current amount which could still technically be reached, but is much less likely and the user may start hitting browser limitations by that point. I picked the 20 bit number since it gives us enough buffer over the 16 bit one, while not being as massive as a 24 bit or 32 bit. I've also added a dev mode assertion so it's easier to track down if it happens again in the future. Fixes angular#37876.
6a44bb0
to
a883497
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good and this is corner case but still it would be good to have a test for this particular scenario. Do you think it would make sense to generate a directive with a large number of host bindings (256+) and a template with 256+ usages of such directive? Or did you assume that it is impractical / not worth having a test for this case?
I thought that it would be impractical and it wouldn't provide much value. The basic logic is already covered by other test cases and all we'd be testing is higher and higher numbers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… bindings (#38014) We currently use 16 bits to store information about nodes in a view. The 16 bits give us 65536 entries in the array, but the problem is that while the number is large, it can be reached by ~4300 directive instances with host bindings which could realistically happen is a very large view, as seen in #37876. Once we hit the limit, we end up overflowing which eventually leads to a runtime error. These changes bump to using 20 bits which gives us around 1048576 entries in the array or 16 times more than the current amount which could still technically be reached, but is much less likely and the user may start hitting browser limitations by that point. I picked the 20 bit number since it gives us enough buffer over the 16 bit one, while not being as massive as a 24 bit or 32 bit. I've also added a dev mode assertion so it's easier to track down if it happens again in the future. Fixes #37876. PR Close #38014
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
… bindings (angular#38014) We currently use 16 bits to store information about nodes in a view. The 16 bits give us 65536 entries in the array, but the problem is that while the number is large, it can be reached by ~4300 directive instances with host bindings which could realistically happen is a very large view, as seen in angular#37876. Once we hit the limit, we end up overflowing which eventually leads to a runtime error. These changes bump to using 20 bits which gives us around 1048576 entries in the array or 16 times more than the current amount which could still technically be reached, but is much less likely and the user may start hitting browser limitations by that point. I picked the 20 bit number since it gives us enough buffer over the 16 bit one, while not being as massive as a 24 bit or 32 bit. I've also added a dev mode assertion so it's easier to track down if it happens again in the future. Fixes angular#37876. PR Close angular#38014
We currently use 16 bits to store information about nodes in a view. The 16 bits give us 65536 entries in the array, but the problem is that while the number is large, it can be reached by ~4300 directive instances with host bindings which could realistically happen in a very large view, as seen in #37876. Once we hit the limit, we end up overflowing which eventually leads to a runtime error.
These changes bump to using 20 bits which gives us around 1048576 entries in the array or 16 times more than the current amount which could still technically be reached, but is much less likely and the user may start hitting browser limitations by that point.
I picked the 20 bit number since it gives us enough buffer over the 16 bit one, while not being as massive as a 24 bit or 32 bit.
I've also added a dev mode assertion so it's easier to track down if it happens again in the future.
Fixes #37876.