mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Scott Valentine <scottvalen@hotmail.com>
To: musl@lists.openwall.com
Cc: Szabolcs Nagy <nsz@port70.net>,
	Justin Cormack <justin@specialbusservice.com>
Subject: Re: LUA + musl, garbage collection issue?
Date: Tue, 23 Sep 2014 20:14:51 -1000	[thread overview]
Message-ID: <BLU436-SMTP1606516841D7B5F6E0446DCC0B10@phx.gbl> (raw)
In-Reply-To: <20140924055001.GA21835@port70.net>

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.

-- 



      reply	other threads:[~2014-09-24  6:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-21  2:41 Scott Valentine
2014-09-21  4:38 ` Rich Felker
2014-09-21  9:58   ` Scott Valentine
2014-09-21 10:16   ` Justin Cormack
2014-09-24  5:25     ` Scott Valentine
2014-09-24  5:50       ` Szabolcs Nagy
2014-09-24  6:14         ` Scott Valentine [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BLU436-SMTP1606516841D7B5F6E0446DCC0B10@phx.gbl \
    --to=scottvalen@hotmail.com \
    --cc=justin@specialbusservice.com \
    --cc=musl@lists.openwall.com \
    --cc=nsz@port70.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).