lgi-devs / lgi-devs/lgi

Memory corruption with g_spawn_async_with_pipes

Open
#245 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
491
Forks
81
PR merge metrics
No merged PRs in 30d

Description

Version 0.9.2-2+b1 (Debian package), reproduces on Lua 5.1, 5.2 and 5.3. Host architecture is i686.

Sample code:

local GLib = require('lgi').GLib
local N = 1000000

local envp = {}
for i = 1, N do
	envp[#envp + 1] = ('VAR%u=%u'):format(i, i)
end

GLib.spawn_async_with_pipes('.', { '/bin/true' }, envp, { }, nil)

Depending on the value of N and the Lua version, this may corrupt the heap and fail an assertion on subsequent realloc or crash immediately.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the sample with Lua 5.1, 5.2, and 5.3 on the reported i686 environment, varying N and observing heap corruption around GLib.spawn_async_with_pipes. Trace the binding entry point for that call and its handling of the envp table; done means the sample no longer corrupts memory or crashes during subsequent allocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.