[prev in list] [next in list] [prev in thread] [next in thread] 

List:       musl
Subject:    Re: [musl] LUA + musl, garbage collection issue?
From:       Scott Valentine <scottvalen () hotmail ! com>
Date:       2014-09-24 6:14:51
Message-ID: BLU436-SMTP1606516841D7B5F6E0446DCC0B10 () phx ! gbl
[Download RAW message or body]

On Wednesday, September 24, 2014 07:50:01 AM Szabolcs Nagy wrote:
> * Scott Valentine <scottvalen@hotmail.com> [2014-09-23 19:25:47 -1000]:
> > 
> > In any case, this has been a nasty issue to track down. I have surely traced it \
> > to the following code block in luci (by process of elimination): 
> > local fp
> > luci.http.setfilehandler(
> > function(meta, chunk, eof)
> > if not fp then
> > if meta and meta.name == "image" then
> > fp = io.open(image_tmp, "w")
> > else
> > fp = io.popen(restore_tmp, "w")
> > end
> > end
> > if chunk then
> > fp:write(chunk)
> > end
> > if eof then
> > fp:close()
> > end
> > end
> > )
> > 
> > 
> > Here, "chunk" is a 2048 byte string, and the library calls are to nixio:
> > 
> 
> are you sure the nixio function is called?
> 
> if fp is not set then io.open is called which should
> use libc fopen, so fp:write should be a wrapper around
> fwrite

> if the code really calls the nixio function below then
> there is no stdio involved, it directly writes to an fd

You are correct... My brain must be getting tired. 
 
> > static int nixio_file_write(lua_State *L) {
> > int fd = nixio__checkfd(L, 1);
> > size_t len;
> > ssize_t sent;
> > const char *data = luaL_checklstring(L, 2, &len);
> > 
> > if (lua_gettop(L) > 2) {
> > int offset = luaL_optint(L, 3, 0);
> > if (offset) {
> > if (offset < len) {
> > data += offset;
> > len -= offset;
> > } else {
> > len = 0;
> > }
> > }
> > 
> > unsigned int wlen = luaL_optint(L, 4, len);
> > if (wlen < len) {
> > len = wlen;
> > }
> > }
> > 
> > do {
> > sent = write(fd, data, len);
> > } while(sent == -1 && errno == EINTR);
> > if (sent >= 0) {
> > lua_pushinteger(L, sent);
> > return 1;
> > } else {
> > return nixio__perror(L);
> > }
> > }
> > 
> 
> 
> > When I have time, I'll do a build against eglibc with a reduced BUFSIZ = 1024 \
> > (musl's default) and see if the problem is reproduced. 
> 
> i think you should try to reproduce the bug with a minimal
> test-case where either stdio (io.*) is called or nixio only

Yes, now that you've pointed out the above, I have something I can work with. I \
should be able to write a pure lua script to try and reproduce the problem.

-Scott V.

-- 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic