From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9D5C3469719 for ; Thu, 20 Feb 2020 00:42:46 +0300 (MSK) Date: Thu, 20 Feb 2020 00:42:45 +0300 From: Nikita Pettik Message-ID: <20200219214245.GD40100@tarantool.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH 1/1] app: os.setenv() affects os.environ() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org On 06 Feb 23:47, Vladislav Shpilevoy wrote: > os.setenv() and os.environ() are Lua API for > > extern char **environ; > int setenv(); > > The Open Group standardized access points for environment > variables. But there is no a word about that environ never > changes. Programs can't relay on that. For example, addition of > a new variable may cause realloc of the whole environ array, and > therefore change of its pointer value. That was exactly the case > in os.environ() - it was using value of environ array remembered > when Tarantool started. > > And os.setenv() could realloc the array and turn the saved pointer > into garbage. > > Closes #4733 > --- LGTM