Re: [Vala] Memory safety



On 15/05/2014 10:18, Florian Weimer wrote:
Hi,

am I correct in assuming that Vala is supposed to inherit the lack of memory safety from C? Or put differently: If there is Vala code that does not guard callers from memory safety violations but it could do so, this is not a problem because callers are generally expected to fulfill such (implicit) preconditions.

Vala inherits the problem of C, yes. You could certainly do some evil casts like in C. Vala however is certainly safer than C in many aspects, in other aspects however you have to know what you are doing and how Vala compiles down to C in certain cases.
For example:
1. func1(): create a local array
2. Call async func2(array) without waiting the function to finish
3. Return from func1
4. func2 runs with a dangling pointer to the array

Vala is not free of rough edges, it makes your life easier. But since a Vala array is a standard C array, it can't be referenced counted and that's why you get the above (unwanted from a newbie perspective) behavior.

Best regards


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]