|
| 05 Jun 2013 06:35 PM |
I have been working with metatables for quite a few months now, and finally got around to using __newindex. I tried to set a value in the __newindex function, and voila, my first C stack overflow!
When did you guys get your first C stack overflow, and less importantly, how do I fix my problem? |
|
|
| Report Abuse |
|
|
EuIer
|
  |
| Joined: 20 Sep 2012 |
| Total Posts: 31 |
|
|
| 05 Jun 2013 06:51 PM |
My first C stack overflow:
function Bob() Bob() end
Bob()
About your problem, you have to be more specific on what you are trying to do. |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
| |
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 05 Jun 2013 06:58 PM |
Use rawset. e.g. use of default way of assigning values within the __newindex metamethod asdf = {} setmetatable(asdf, { __index = asdf, __newindex = function(t,i,v) v = 5 -- causes C stack overflow end }) asdf[#asdf + 1] = 4 print(asdf[1]) --> blarg e.g. use of using rawset to assign values within the __newindex metamethod local asdf = {} setmetatable(asdf, { __index = asdf, __newindex = function(_,i,v) rawset(_,i,5) end }) asdf[#asdf + 1] = 4 print(asdf[1]) --> 5 |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2013 07:30 PM |
@129K Thanks, that makes sense. I am assuming there's a wiki article, so I'll use it as reference.
Also, what was your first C stack overflow? c: |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
| |
|
belial52
|
  |
| Joined: 10 Oct 2009 |
| Total Posts: 8074 |
|
|
| 05 Jun 2013 08:53 PM |
| @Waffle, Just get lost. You don't post anything helpful, EVER. He was definitely talking about Lua and not any kind of C language. |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 05 Jun 2013 09:04 PM |
| Get out stupid kiddie. `a=function()a()end a()` is not a 'C stack overflow', it is just a Lua stack overflow. This thread is about C stack overflows. |
|
|
| Report Abuse |
|
|
HaxHelper
|
  |
| Joined: 19 Dec 2009 |
| Total Posts: 1208 |
|
|
| 05 Jun 2013 09:05 PM |
waffle
just because someone isn't as much of a genius as you are doesn't give you the right to make condescending comments
now let's please forget about this and return to the thread |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 05 Jun 2013 09:09 PM |
"just because someone isn't as much of a genius as you are" > allegedly is not as much of a genius as I am "@Waffle, Just get lost. You don't post anything helpful, EVER." > is making condescending comments
What are you implying by this? |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 05 Jun 2013 09:13 PM |
| u guys are ideits!!!!!!!!!!!!!!!!!!!!!!! |
|
|
| Report Abuse |
|
|
HaxHelper
|
  |
| Joined: 19 Dec 2009 |
| Total Posts: 1208 |
|
| |
|
|
| 05 Jun 2013 09:39 PM |
Hey guys, I actually ran into this same problem a few minutes ago when I was trying to modify the environment so that 1+1=3. I don't have the code - didn't think I'd need two-minute code - but I do know rawset was not working. It went something along the lines of
local meta = { __newindex = function(t,v,i) -- code rawset(t,v,i) -- C Stack Overflow end }
local new_env = {a bunch of stuff here}
setmetatable(new_env, meta)
setfenv(1, new_env) -- or maybe it was 0? I don't use fenv functions often so I debug them on the spot.
a = 1 |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2013 09:40 PM |
Whoops, forgot the question
Anyone know why rawset wasn't working? Or maybe a way to get around the overflow? |
|
|
| Report Abuse |
|
|
SN0X
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 7277 |
|
|
| 06 Jun 2013 12:19 AM |
I got C stack overflow like yesterday....
idc |
|
|
| Report Abuse |
|
|
BAUER102
|
  |
| Joined: 03 Apr 2010 |
| Total Posts: 5936 |
|
|
| 06 Jun 2013 09:43 AM |
Your other code must have caused the C-stackoverflow, ArceusInator.
I'm not getting an error when running your code.
Post the missing stuff here? |
|
|
| Report Abuse |
|
|
belial52
|
  |
| Joined: 10 Oct 2009 |
| Total Posts: 8074 |
|
|
| 06 Jun 2013 03:17 PM |
| @Waffle, If it weren't for the fact that every post I ever see you make is something stupid like your first post on this thread, maybe I'd reconsider what I said, however, most of what I see you post is something along those lines. A C-stack overflow is when you call something Lua side of the program enough to cause an error. It is not an issue in a C language of any kind. So, as previously stated, please, just get lost. |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 06 Jun 2013 03:45 PM |
| Do you honestly believe that OP's first stack overflow was caused by metamethods and not some simple loop? I think this thread http://www.roblox.com/Forum/ShowPost.aspx?PostID=100223032 is a good list of far more probable instigators of this problem. |
|
|
| Report Abuse |
|
|
badcc
|
  |
| Joined: 18 Jan 2009 |
| Total Posts: 3170 |
|
|
| 06 Jun 2013 03:45 PM |
Everyone complains about all the spam in the Scripters forum. Finally someone comes who wants to get rid of them and actually is doing well, and you all get angry at him. Let 1waffle1 do his thing, he's helping and whether or not you know it, he has a lot of knowledge and is actually using it.
He is correct. |
|
|
| Report Abuse |
|
|
nairod7
|
  |
| Joined: 26 Mar 2010 |
| Total Posts: 869 |
|
|
| 06 Jun 2013 03:57 PM |
@badcc
Actually, spams in the Scripters subforum make it live in a sense. I'm not opposed to what waffle's doing, each one have his own methods to answer to irrelevant threads or ones which aren't in the right subforum, however there's not enough /good/ scripters who're posting interesting threads on advanced topics. So, only /bad/ threads are remaining and people who're looking at this section doesn't consider it as an /advanced subforum/. Consequently, there're more spam threads. |
|
|
| Report Abuse |
|
|
|
| 06 Jun 2013 04:07 PM |
| I am confused. Is 1waffle1 calling my thread spam? And then suggests that I am talking about every kind of stack overflow, when I am talking about C stack overflows...? |
|
|
| Report Abuse |
|
|