Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

ConstraintGear2D: AccessViolationException when trying to add it to the node #50

Closed
EgorBo opened this issue Aug 2, 2015 · 9 comments
Closed
Labels

Comments

@EgorBo
Copy link
Member

EgorBo commented Aug 2, 2015

32_Urho2DConstraints C# (Line 344)
someNode.CreateComponent()
or
someNode.AddComponent(new ConstraintGear2D(Context));

throw AccessViolationException

@EgorBo EgorBo added the bug label Aug 2, 2015
@migueldeicaza
Copy link
Contributor

Please provide a stack trace

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2015

@migueldeicaza looks like it caused by overflow of StringHash.Code field (it should be uint instead of int) because now for that specific class (ConstraintGear2D) the StringHash LookupStringHash returns hash with a negative big code.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2015

I've just checked - ConstraintGear2D::GetTypeStatic() returns 4159594590 (almost twice larger than Int32.MaxValue).
Same crash happens for several types (samples).

@migueldeicaza
Copy link
Contributor

I am confused, can you produce a small reproduction test case?

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2015

@migueldeicaza
um...
just execute this in C#: (Samples project, Program.cs)

var valueMono = ConstraintGear2D.TypeStatic.Code;

valueMono is -135372706
same code in C++

auto valueCpp = ConstraintGear2D::GetTypeStatic();

valueCpp is 4159594590

but they should be the same. that's because of int type of Code field in StringHash instead of uint (used in C++ version).

@migueldeicaza
Copy link
Contributor

They are internally the same value. Both -135372706 and 4159594590 are the same bit pattern (0xf7ee605e).

So the question is: how do I reproduce the crash, not how do I reproduce the two values rendering differently.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 5, 2015

Oh, you are right, they are the same. let me collect the stacktrace.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 11, 2015

I've filed an issue - #54

@EgorBo
Copy link
Member Author

EgorBo commented Aug 11, 2015

closing with #54 with fix 85b3fc0 fix is verified.

@EgorBo EgorBo closed this as completed Aug 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants