[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [RESEND PATCH 03/12] golang/xenlight: fix string conversion in generated toC functions
On Fri, Jun 18, 2021 at 11:00:26AM +0000, George Dunlap wrote: > > > > On May 24, 2021, at 9:36 PM, Nick Rosbrook <rosbrookn@xxxxxxxxx> wrote: > > > > In gengotypes.py, the toC functions only set C string fields when > > the Go strings are non-empty. However, to prevent segfaults in some > > cases, these fields should always at least be set to nil so that the C > > memory is zeroed out. > > > > Update gengotypes.py so that the generated code always sets these fields > > to nil first, and then proceeds to check if the Go string is non-empty. > > And, commit the new generated code. > > > > Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx> > > So wait — if you do > > var foo C.typename > > Then golang won’t automatically zero out `foo`? > > That seems like a bug really; but assuming this fixes real behavior you’ve > encountered: I would have to dig in again to figure out exactly what Go/cgo is doing here, and whether or not this is a bug. But, the behavior I observed was that without these nil assignments, I would sometimes get segfaults in libxl_string_copy. This patch ensures that libxl__str_dup is not called in the empty string case, thus avoiding the segfault. > > Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx> Thanks, NR
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |