#bitfighter IRC Log

Index Search ←Prev date Next date→

IRC Log for 2012-04-11

Timestamps are in GMT/BST.

00:32:52BFLogBot - Commit 40b254a6084b | Author: watusim...@bitfighter.org | Log: Rename method printToOglConsole to printToConsole (could affect some lua scripts)
00:32:54BFLogBot - Commit adcc92474cb1 | Author: watusim...@bitfighter.org | Log: More efficient script startup, other cleanup and reorg
00:32:55BFLogBot - Commit 470be8015578 | Author: watusim...@bitfighter.org | Log: Merge
00:41:06Watusimoto Quit (Ping timeout: 246 seconds)
03:00:36Heyub Quit (Quit: KVIrc 4.0.4 Insomnia http://www.kvirc.net/)
03:40:09raptor has joined
03:42:03raptor Quit (Client Quit)
04:21:57raptor has joined
04:21:57ChanServ sets mode +o raptor
04:22:02raptorgood evening
04:49:41raptor Quit (Quit: Page closed)
05:38:34kodaws has joined
08:09:14watusimoto has joined
08:09:15ChanServ sets mode +o watusimoto
08:12:14sam686 Quit (Ping timeout: 245 seconds)
09:51:47Watusimoto_ has joined
10:45:46Watusimoto_ Quit (Ping timeout: 252 seconds)
11:24:39kodaws Quit (Ping timeout: 240 seconds)
12:53:06Watusimoto_ has joined
14:29:12Watusimoto_ Quit (Ping timeout: 246 seconds)
14:41:14raptor has joined
14:41:14ChanServ sets mode +o raptor
14:41:27raptorgood day
14:50:15raptor changes topic to 'Bitfighter 017a released!: http://bitfighter.org/downloads'
14:50:19raptor has left
14:50:21raptor has joined
14:50:21ChanServ sets mode +o raptor
14:51:51watusimotohi
14:51:58raptorhello
14:52:37raptori haven't tested your latest changes yet..
15:01:12watusimotothat's ok.-- neither have I
15:01:16watusimotook, off to german class
15:01:18raptorha
15:01:20raptorlater
15:02:07raptorseg fault
15:02:24raptorprobably need to copy over new scripts..
15:03:58raptorvalid segfault: http://pastie.org/3768556
15:04:27BFLogBot - Commit a9616c2d3f40 | Author: buckyballreaction | Log: Remove s_bot from exe folder (again) since it is in resources
15:41:14raptorsecond valid segfault: http://pastie.org/3768782
15:41:35raptorfirst is starting a level with a levelgen; second is with adding bot to a normal level
16:30:22watusimotoany invalid segfaults?
16:30:34raptorhehe
16:30:46raptorjust got those two.. and i made sure to copy over the new resources
16:30:56raptorand clean compile
16:31:30watusimotolevelgens not yet working!
16:31:50watusimotolets look at the second
16:32:22raptorboth have to do with lua environment set, i think
16:32:47watusimotoyes
16:32:50watusimotothe second
16:32:54watusimotovoid LuaScriptRunner::setEnvironment(const char *environmentName, bool environmentIsGlobal)
16:32:54watusimoto{
16:32:55watusimoto // Grab the script's environment table from the registry, place it on the stack
16:32:55watusimoto if(environmentIsGlobal)
16:32:55watusimoto lua_getglobal(L, environmentName); // -- function, table
16:32:55watusimoto else // ** OR **
16:32:55watusimoto lua_getfield(L, LUA_REGISTRYINDEX, environmentName); // -- function, table
16:32:56watusimoto lua_setfenv(L, -2); // -- function
16:32:56watusimoto}
16:32:57watusimotothat's the methods
16:33:06watusimotoit segfaults at the setfenv
16:33:23watusimotoprobably there is not enough stuff on the stack, or it's the wrong kind of stuff
16:33:43watusimotoif you insert a LuaObject::dumpStack(L) just before the setfenv, you can see what is on the stack
16:33:54watusimotothe comments tell you what to expect
16:34:01watusimotoin this case, we expect a function and a table
16:34:29watusimotothe function is the code we are about to execute in whatever is calling this function
16:34:55watusimotoand the table is our "robot environment" -- a special little universe in which the robot lives
16:35:35watusimotoI'm guessing that the table is nil for some reason, so the stack would have a function and a nil
16:35:44raptorTotal in stack: 3 [listed bottom to top]
16:35:45raptorstring: 'scripts/sandbox.lua:3: bad argument #1 to 'pairs' (table expected, got nil)'
16:35:47raptorfunction
16:35:48raptornil
16:35:50raptorSegmentation fault
16:35:52watusimotook
16:36:01watusimotothe string is an error message left over from somewhere else
16:36:09watusimotoso something got mucked up before here
16:36:26watusimotodo you have a script called sandbox.lua?
16:37:07watusimotosandbox is supposed to create a copy of the global environment.
16:37:24watusimotoand it failed for some reason
16:37:31raptornope
16:37:37raptori just /addbot
16:37:45raptorwait
16:37:47watusimotook, that's the problem
16:37:51raptorlet me look... is that a new one?
16:37:55watusimotonew
16:37:57watusimotoish
16:38:08watusimotoit should be in the same folder as lua_helper_scripts.lua
16:38:08raptorok
16:38:11raptori found it
16:38:12raptorit's there
16:38:24raptorlua_helper_functions
16:38:41watusimotocan you paste the contents here?
16:38:45watusimotoit's short
16:39:02raptorfunction table.copy(t)
16:39:04raptor local u = { }
16:39:05raptor for k, v in pairs(t) do u[k] = v end
16:39:07raptor return setmetatable(u, getmetatable(t))
16:39:08raptorend
16:39:10raptorsandbox_env = table.copy(_G)
16:39:12raptor^^ that's sandbox.lua
16:39:30watusimotoso it's that for line that broke
16:39:57raptorthat looks like just a copy
16:39:58watusimotook
16:40:22watusimotoso sandbox_env = table.copy(_G) should copy _G
16:40:27watusimotobut it's not finding _G
16:40:31raptorpairs(t) is wrong?
16:40:35watusimoto_G is the global variable table
16:40:36watusimotono
16:40:39watusimotoit's right
16:40:56watusimotoprobably we did something to destroy _G, or otherwise make it unavailable
16:41:13raptoris _G the standard global stack?
16:41:19watusimotoglobal table
16:41:28watusimotothe stack is only for interfacing with C/C++
16:41:32raptorah ok
16:41:42watusimotoI think
16:41:58watusimotolooking at the C++ clode, we are running sandbox.lua in a brand new L
16:42:03watusimotoright after it is created
16:42:59watusimotowait a minute
16:43:32watusimotoaha
16:43:42watusimotoI must not have checked in my copy of sandbox
16:44:38watusimotochange sandbox_env = table.copy(_G) to robot_env = table.copy(_G) and add levelgen_env = table.copy(_G) and see if that fixes it
16:44:57raptorso 2 lines in place of one?
16:45:00watusimotowe are creating two copies of _G, one for robots and one for levelgens
16:45:01watusimotoyes
16:45:19watusimotothough we don't really need to anymore, that's what the C++ is expecting
16:46:05watusimotovoid Robot::prepareEnvironment() looks for a table called robot_env
16:46:06raptorafter that change, no crash when loading a levelgen level (but levelgen is borken)
16:46:19watusimotoas is expected
16:46:45raptors_bot added just fine to a normal level
16:46:51watusimotook, good
16:46:52raptorand has proceeded to kill me a number of times..
16:47:02watusimotoso you can check in the sandbox script
16:47:05raptorok
16:47:10watusimotoI'll probably get rid of it tonight
16:47:37watusimotobecause we really only need the table.copy, and maybe we don't even need that
16:47:57raptorok pushed
16:48:05watusimotothe only reason we copy the globals table is to keep a rogue bot from destroying the scripting environment for other bots
16:48:20watusimotoand I'm not too worried about malicious bots
16:49:21raptorevil bots
16:49:33watusimotoespecially if we get rid of the ability of bots to write to disk
16:49:40BFLogBot - Commit f4389bbde572 | Author: buckyballreaction | Log: Watusimoto says this fixes the segfaults with loading levelgens and robots
16:49:42raptorwhat!?
16:49:46raptorthey have that ability?
16:49:51watusimotoI think so
16:50:03watusimotoright now, we run this:
16:50:04watusimotoluaL_openlibs(L);
16:50:16watusimotothis adds all the standard libs to the lua environment
16:50:41watusimotowe might get rid of some of the capabilities in lua_helper_xxx.lua
16:50:53watusimotowe did at one point, anyway
16:51:17watusimotobut I am not worried about making an airtight sandbox
16:51:45watusimotoif someone writes a bot that crashes bitfighter, as long as it doesn't take down the OS as well, it's probably ok
16:52:00watusimotoat least until we allow remote execution of scripts
16:52:12raptorhaha
16:52:21watusimotobut since the server operator must install all scripts, I don't think the danger is too high
16:52:36watusimotook, I've got to go
16:52:43raptorspeaking of remote execution... do you think it would be useful for the master server to shutdown dedicated servers?
16:52:50raptorok
16:52:51watusimotowill do more lua cleanup tonight
16:52:52raptorsee you later
16:52:53watusimotowhy?
16:53:11raptorthere was a case where one server operator had 4 copies of the same server up
16:53:26raptorhe swore that he had only one instance of bitfighterd running, but we new better...
16:53:29raptor*knew
16:53:37watusimotohuh
16:53:48raptorwe had to convince him to double check his process list for all users
16:53:49watusimotono, I don't think we need that capability
16:53:52raptorok
16:54:04raptorit was just a thought
16:54:10watusimotoit sounds like an isolated case of a spazzy op that once he learned better problem fixed
16:54:17raptoryes
16:54:18watusimotook, well, see you later
16:54:20raptorlater
17:18:55Watusimoto_ has joined
17:19:15Watusimoto_hi
17:19:19raptorhello
17:26:31Watusimoto_do you agree we are not overly concerned with one bot intentionally trampling on another's code?
17:26:43raptoruhh...
17:26:49raptori'm not really
17:27:36Watusimoto_maybe we could have a metagame of corewars going on with the bots
17:27:46Watusimoto_they battle on the field and in the memory
17:28:21raptora tron-like environment?
17:28:28raptorso wait
17:28:48Watusimoto_do you know corewars?
17:29:06raptorare you saying that there is a possibility one bot access code form another of the same bot?
17:29:10raptormaybe...
17:29:15raptorlet me jog my memory..
17:29:31Watusimoto_two assmebler programs trying to overwrite the others' memory
17:29:51raptorha!
17:29:55raptorno, i've never seen this before..
17:30:07Watusimoto_I used to be really into it
17:30:40Watusimoto_anyway
17:31:11Watusimoto_before, when each bot was in it's own L (Lua instance), there was no issue
17:31:18Watusimoto_now they all run in the same :
17:31:19Watusimoto_L
17:31:33Watusimoto_so there is the possibiliy of bots interfering with each other
17:31:39raptoryes, with swapping tables right?
17:31:43Watusimoto_all bots share the same globals table
17:32:08Watusimoto_but create these "functional environments" that sort of simulate a local globals table
17:32:26Watusimoto_these environments (one per script) can be made pretty watertight
17:32:31raptorso if i create a global in s_bot with name 'var', and another in orbitbot with the same name, what happens?
17:32:50Watusimoto_each bot's var gets wrtitten to the local environment. no problem
17:32:55Watusimoto_no conflict
17:32:57raptorok
17:33:38Watusimoto_one way to do the bots is to make a complete copy of the _G table, and give it to each bot, then cut off all further access to that table
17:33:53Watusimoto_that, combined with blotting out "dangerous" functions, creates a reasonably good sandbox
17:34:20Watusimoto_but you need to copy the _G table for every bot, which takes time and consumes memory
17:34:28raptorin what way could sharing _G be bad? it'd have to be done in the c++ code, right?
17:34:29Watusimoto_theoretically, all could share this _G table
17:34:37raptoror
17:34:53Watusimoto_well, for example, the print function is stored in the _G table
17:34:53raptoris _G modifiable by *any* script if you specify it?
17:35:03Watusimoto_you could overwrite _G["print"] = nil
17:35:07Watusimoto_no more print function
17:35:59Watusimoto_in the sandbox example, access to _G gets rerouted to the function's environment table; if they run that code, that bot has no more print function, but the other bots are happy
17:36:25raptorah ok
17:36:25Watusimoto_You can crate a "metatable" for each table
17:36:37raptoris it a large table?
17:36:59Watusimoto_that metatable handles access to requests for values not in the bot's environment table
17:37:26raptorsafest is to copy _G
17:37:32Watusimoto_my first attempt, the one described on stackoverflow, was to give each bot its own environment table, but let them share _G as a metatable
17:37:45raptorand is it really that much more overhead?
17:38:02Watusimoto_so if a bot requested an enum value, for example, it would first check its own table, not there, then go to the global table
17:38:08Watusimoto_(transparently to the bot)
17:38:18Watusimoto_I don't know how much overhead it really is
17:38:43Watusimoto_for running 1-2 bots, it's nothing
17:39:01LordDVG has joined
17:39:49Watusimoto_hello?
17:39:54raptorhi
17:40:01Watusimoto_with /addbots 100, there is a reasonable delay
17:40:09Watusimoto_no idea about the memory overhead
17:40:23Watusimoto_probably not too much
17:40:28raptorreasonable delay that is comparative to not copying _G?
17:40:33Watusimoto_but I'm not doing the real sandbox
17:40:55Watusimoto_for example, one of the things that gets copied is the print function
17:41:02Watusimoto_I am copying a pointer to the print function
17:41:06Watusimoto_not the function itself
17:41:32Watusimoto_I don't know how much more overhead will come from doing a deep copy of _G
17:41:46Watusimoto_but I found this snippet
17:41:46raptorlet me run a test with current revision
17:41:50Watusimoto_ok
17:41:51Watusimoto_/local env = setmetatable({}, {__index=function(t,k) if k=='_G' then return nil else return _G[k] end})
17:41:55raptor100 bots was ~30MB RAM
17:42:00raptorbefore
17:42:37Watusimoto_this would let _G be a metatable for reading, but if you tried to do _G["print"] = nil, it would fail
17:43:00Watusimoto_and if you did print = nil
17:43:14Watusimoto_that would create a local copy of print that was nil, and would not b0rk other bots
17:43:26raptorshould _G be allowed to be modified by bots? i'd say no...
17:43:30Watusimoto_no
17:43:47Watusimoto_definitely not
17:44:03raptori don't know what you did since last test, but RAM for 100 bots is now 18.7M
17:44:06Watusimoto_the question is do we make it impossible, or just difficult to do by accident?
17:44:09raptoreven less
17:44:23raptori'd say impossible
17:45:19raptoroh yeah - we added the control tick
17:45:21Watusimoto_well I'm kind of wavering on that
17:46:35Watusimoto_I like the idea of total isolation, but I am not sure about the cost
17:46:55raptorhow can i test the cost of non-total isolation with the current revision?
17:46:57Watusimoto_and I am having trouble finding a use case where it would really be helpful
17:46:59raptoris it an easy change?
17:47:06Watusimoto_not sure
17:47:16Watusimoto_maybe we have total isolation
17:47:26Watusimoto_now that I think through it a little more
17:47:46Watusimoto_how could one bot b0rk another's print function?
17:48:06Watusimoto_not sure it could
17:48:29Watusimoto_but with the code I posted above, I'm not sure it could, either... just not sure
17:49:11raptoryeah, actually, i'm thinking don't copy the global table
17:49:29Watusimoto_so what's the use case for airtight sandboxes?
17:49:53raptorif we allow full lua script functionality
17:50:05raptornot sure why we'd need that, though
17:50:20Watusimoto_I'm not talking about giving bots disk write access or anything -- that's a different issue
17:50:54Watusimoto_I'm thinking of bots screwing up the scripting environment and causing bitfighter to need to be restarted to fix it
17:51:16raptormaybe bitfighter should be more robust on the c++ side
17:51:42raptorbrb
17:58:06raptorback
18:01:34raptoror maybe a level change could 'reset' the scripting environment?
18:02:25Watusimoto_that would work
18:02:47Watusimoto_though not really necessary
18:11:37raptorfound an interesting site: http://opengameart.org
18:11:48raptorthere's sound effects and music there, too
18:14:15Watusimoto_love it already... now let's have a look
18:30:18Watusimoto_dinner time
18:30:29raptorlunch time!
18:35:49Watusimoto_ Quit (Ping timeout: 276 seconds)
20:31:14Watusimoto_ has joined
20:56:56LordDVG Quit (Quit: Leaving)
21:25:09BFLogBot - Commit 575a47c855f8 | Author: watusim...@bitfighter.org | Log: Much improved Lua setup process -- probably can't get too much faster than this
21:36:16raptorooo
21:36:18raptori will test
21:38:34raptorheh
21:38:44raptorcannot open scripts/levels/6357.levelgen
21:38:50raptordir in a dir
21:39:09raptor***ROBOT ERROR*** cannot open scripts/robots/s_bot.bot: No such file or directory -- Aborting
21:39:12raptordir in a dir
21:41:24raptorprobably luaObject.cpp:624?
21:44:28raptoryep that was it
21:44:33raptori fix
21:50:13BFLogBot - Commit b048dd9b56de | Author: buckyballreaction | Log: Fix loading scripts
21:50:24Watusimoto_BFLogBot: levelgens don't work
22:08:03raptorha!
22:08:13raptorrobots didn't work either...
22:37:55sam686 has joined
22:38:02ChanServ sets mode +v sam686
22:44:01raptorok, i'm out
22:44:08raptorbye
22:44:26raptor Quit ()
23:30:27BFLogBot - Commit 2a6b0e6d4925 | Author: watusim...@bitfighter.org | Log: Comment
23:30:29BFLogBot - Commit 46a51e90909c | Author: watusim...@bitfighter.org | Log: Remove sandbox.lua dependency
23:30:30BFLogBot - Commit e32161aefdb8 | Author: watusim...@bitfighter.org | Log: Merge
23:33:42Watusimoto_ Quit (Ping timeout: 250 seconds)

Index Search ←Prev date Next date→

These logs were automatically created by BFLogBot on irc.freenode.net.