Hi, I ran the clang static analyzer and it found a few potential issues. For example in primitiveScanCharacters :
[image: Images intégrées 1]
we (tpr) did not protect the result of: stops := self stackObjectValue: 1.
with a: self successful ifFalse: [^ nil].
since stackObjectValue: will return nil (null) if the object is immediate: stackObjectValue: offset "Ensures that the given object is a real object, not a SmallInteger." "In the StackInterpreter stacks grow down." | oop | oop := stackPages longAt: stackPointer + (offset * objectMemory wordSize). (objectMemory isImmediate: oop) ifTrue: [self primitiveFail. ^ nil]. ^oop
then if we don't return now but insist on testing object class, we are dereferencing null pointer...
Of course, this is theoretical, because it's necessary to put a SmallInteger in stops, which will make the image pretty unusable whether the VM crashes or not, but we should generally care to avoid spurious crashes...
I propose a minor rewrite for this one attached... It would be a good idea to verify if there are more holes...
Nicolas
On 30-03-2015, at 2:41 PM, Nicolas Cellier nicolas.cellier.aka.nice@gmail.com wrote:
Hi, I ran the clang static analyzer and it found a few potential issues. For example in primitiveScanCharacters :
Good catch. I have had myself taken out behind the bike shed and given a Jolly Good Talking To.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Strange OpCodes: DCBP: Detonate Chair on Bad Password
vm-dev@lists.squeakfoundation.org