From: Jean Privat Date: Fri, 29 May 2015 01:40:09 +0000 (-0400) Subject: Merge: Nitg-g new NativeArray fix X-Git-Tag: v0.7.5~12 X-Git-Url: http://nitlanguage.org Merge: Nitg-g new NativeArray fix This is a bug that was discovered during the push of #1403. What happens is that since NativeArrays work only with boxed values, the copy_to operation could write data beyond its intended boundaries, hence corrupting random memory. If you execute the test bundled with the PR, on my machine, with `--hardening` on, you get this error: `BTD BUG: Dynamic type is Sys, static type is Array[Byte]` What happens here is that the `dest` of the `memmove` was in a emplacement before the `Array[Byte]` itself, due to its length and because the `memmove` used val* as sizeof value, it rewrote the classid of `self`, hence changing its dynamic type effectively from `Array[Byte]` to `Sys`, which produces the typing bug. If left too long to execute, or in an unlucky memory layout, it simply segfaulted. The behaviour of NEW_NativeArray henceforth is that it will reserve space for n `val*` instead of the `ctype` of the values. Pull-Request: #1417 Reviewed-by: Jean Privat Reviewed-by: Romain Chanoir --- 470cd273fa6a110cd62d4b01c51e73a5aa3a83c3