Primitive 177 bug

A BlockClosure can have varying arguments. The method #valueWithArguments: is usefull, if you write code that will dynamically evaluate BlockClosures.

If you evaluate a BlockClosure with zero arguments using #valueWithArguments: #() the VM terminates without any further messages.

Example:

[codesyntax lang=”smalltalk”]

[5] valueWithArguments: #().

[/codesyntax]

Reason:

The primitive compares the number of necessary block arguments with the size of the arguments array. If this test is positive the primitive assumes at least one argument and enters a loop that pushes arguments on the stack and decrements an internal counter, that is initialized with the size of the arguments array. If the argument array has zero size decrementing this value will result in 0xFFFFFFFF, which causes the stack being filled with garbage until a CPU stack overflow happens.