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

Re: [RESEND PATCH 02/12] golang/xenlight: fix StringList toC conversion


  • To: Nick Rosbrook <rosbrookn@xxxxxxxxx>
  • From: George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Date: Fri, 18 Jun 2021 10:51:11 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LDuMz/juPY5gWNhy1V2tssudSm86+7xqWVv9XlGfvBY=; b=clDwNdx0wwTJO9tmf3cOqQuO0+xjoDnEfDzuKMxpyC15Ay/vH1Hz5bYeH5oI4fWYzwq8nWjOShMZP6hCu5bLBxRPkri4pzXd1wFRU3kOE2ocGdmZbSj4QicILa2aT6ShwEFoYP1DYM20RS+o+Nkpm697Ic4907jducCtYByoJhebHdtcPKcfKoFZPVloAWJxlpDrRXYggkugnh9UXr07+yesdyz26/XiJ9V/eUUMoMlPU40PWExDfWfIsaTrb5eV0lKUvfEATpAw72wBhDYdrCT7EENoXQUegOGjuN/Sx7SWexhUvRr05QjjGrQ8T0pKFadwu3w13+WRzBDJxgDSrw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKNdXtHxdc42/GN4zyiLt8lPZ27rOsasvv+PObgXsRGrvCUu4Tf+ric5YqN01C6pEBQmbLagmE87N2fee051aV206dZFh5I/Lak1H7p7kcK/x4p3a7oL6zNOCvwJ7wyjvRwp6LwHwpgnSth5tWG/yVw2drGwtjyzVS8vpfcOR1arNYVcN50GAOV/vIRSqe/FBcVDj1ru9UMWkKJ16Pape0DpclzI74EdIgyq6eeoMMxJZ6IifqDNdMtRQcNvWVZDSVcXRX+WzDxPEDss+Wt39yXLZ9INea/2MC7a5h/i0t01wY/Cs/ZJ7TDJlZmMdnJ498DxzoVKD+K7ym8+tIpcuA==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 18 Jun 2021 10:51:20 +0000
  • Ironport-hdrordr: A9a23:yLLqFa3bKU8BKKGe6jRPPAqjBQxyeYIsimQD101hICG9Lfb2qy n+ppgmPEHP5Qr5AEtQ5OxpOMG7MBbhHQYc2/hRAV7QZnibhILOFvAj0WKC+UyvJ8SazIBgPM hbAtFD4bHLfDtHZIPBkXOF+rUbsZq6GcKT9J/jJh5WJGkAAcAB0+46MHfhLqQffngaOXNTLu v52iMznUvHRZ1hVLXdOpBqZZmgm/T70LbdJTIWDR8u7weDyRmy7qThLhSe1hACFxtS3LYL6w H+4k7Ez5Tml8v+5g7X1mfV4ZgTssDm0MF/CMuFjdVQAinwizyveJ9qV9S5zXUISaCUmRIXee v30lEd1vdImirsl6aO0EPQMjzboXETArnZuASlaDXY0JbErXkBerV8bMpiA2XkAgwbzY1BOe twrhKknosSAhXakCvn4d/UExlsi0qvuHIn1fUelnpFTOIlGfVsRRx2xjIlLH4sJlOz1GkcKp gkMCgc3ocgTXqKK3TC+mV/yt2lWXo+Wh+AX0gZo8SQlzxbhmpwwUcUzNEW2i5ozuNwd7BUo+ Dfdqh4nrBHScEbKap7GecaWMOyTmjAWwjFPm6eKUnuUKsHJ3XOoZjq56hd3pDmRHXJ9up6pH 3laiIWiYcfQTOaNSS+5uw8zvmWehTOYd3E8LAr23FWgMyOeIbW
  • Ironport-sdr: 1meH1P5UplFF3Qk+CTQUyR3WTiXVVJUBTk3sGZFNPjTNuot4XsS2/Wq3GDwGkRz10IR7+t+JW8 EK7y0CaRqI5zKtrx5bMebzvWaV6+naCiYVY+bE6iXaLlgziYYhaHSTUz11NIk0O64vSz+xXc7M wg7/OHYxuZzijRhVnNTF2w+7+erEAgkxLq0B9WtgN4w7FLQ+BQ48Q1lb7LtwMd0XGpgs6xJZIN VTfCOzAMGr4gqXEJvmRR8KBK5LNStywV57MkniyogCBDKm/PIe4n3NbEIL/3XawOsFJxDn3Xfe rWA=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXUNy7TNv+p7nNOkmLFrh5orF2CasZvfqA
  • Thread-topic: [RESEND PATCH 02/12] golang/xenlight: fix StringList toC conversion


> On May 24, 2021, at 9:36 PM, Nick Rosbrook <rosbrookn@xxxxxxxxx> wrote:
> 
> The current implementation of StringList.toC does not correctly account
> for how libxl_string_list is expected to be laid out in C, which is clear
> when one looks at libxl_string_list_length in libxl.c. In particular,
> StringList.toC does not account for the extra memory that should be
> allocated for the "sentinel" entry. And, when using the "slice trick" to
> create a slice that can address C memory, the unsafe.Pointer conversion
> should be on a C.libxl_string_list, not *C.libxl_string_list.
> 
> Fix these problems by (1) allocating an extra slot in the slice used to
> address the C memory, and explicity set the last entry to nil so the C
> memory will be zeroed out, and (2) dereferencing csl in the
> unsafe.Pointer conversion.
> 
> Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>

Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>

Even as I was making these I thought it might be good to try to get some unit 
tests of this conversion.




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.