[Tarantool-patches] [PATCH 1/1] app: os.setenv() affects os.environ()

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Feb 20 01:44:32 MSK 2020


Hi! Thanks all for the reviews!

Pushed to master, 2.3, 2.2 and 1.10.

Also added a changelog record to the releases draft.
And here too, since I forgot to add it to the cover
letter (or that rule was added after my patch, don't
remember).

@ChangeLog
- os.environ() was not changed when os.setenv() was
  called (gh-4733).

On 19/02/2020 22:42, Nikita Pettik wrote:
> 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
> 


More information about the Tarantool-patches mailing list