ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
Tracing a C stack overflow

1 2 | Next 10 events »| All Messages
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  00:52:55  7 March 2012
profilee-mailreply Message URLTo the Top
Llynix
(Novice)
 
On forum: 12/19/2011
Messages: 47
Tracing a C stack overflow

I'm getting a C stack overflow in the AMK 1.4 I modified. I basically added some simple scripts, like the Atmen script, Limited Bolts, Lurk Inventory Sounds, Health Overhaul and such. Is there some tool I could use for debugging each script to find the culprit behind it?

Could the all.spawn be the source of a C stack overflow? I searched through the forums and found suggestions that it's usually the fault of a bad script in the scripts folder, but I wanted to ask just in case. I removed Tolik from the all.spawn - perhaps that's the source of the error.

Not sure if this is related, but I keep getting an "Unknown command: nil" message in the command screen each time I close the inventory screen, the trade screen or a container. Could this be the reason behind the overflow? And where does this "Unknown command: nil" line come from?

hope someone can help, the CTDs are really annoying.
Thanks and cheers.
  01:20:19  7 March 2012
profilee-mailreply Message URLTo the Top
SetaKat
Ex modder, Zones only ferret and will someday release a game
(Resident)

 

 
On forum: 02/20/2010
Messages: 6342
C Stack overflows are caused by a recursive loop or function call. Basically, just look for a loop somewhere, or a function which calls itself under certain conditions.
  03:56:32  7 March 2012
profilee-mailreply Message URLTo the Top
Lijenstina
Doom metal in the shade of the flying radiators
(Resident)

 

 
On forum: 07/23/2005
Messages: 1902
One of the biggest generator of them are smart terrains and gulags.
  14:03:48  7 March 2012
profilee-mailreply Message URLTo the Top
Llynix
(Novice)
 
On forum: 12/19/2011
Messages: 47

---QUOTATION---
One of the biggest generator of them are smart terrains and gulags.
---END QUOTATION---



Ok.
What about the "Unknown command: nil" message in the command screen? I only get it when I close the inventory or trade/container screen. Can this be related to the issue?
  16:55:32  7 March 2012
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
 

Message edited by:
Meltac
03/07/2012 16:56:31
Messages: 1519

---QUOTATION---
C Stack overflows are caused by a recursive loop or function call. Basically, just look for a loop somewhere, or a function which calls itself under certain conditions.
---END QUOTATION---



Doesn't need to be a recursive loop to produce that type of error, a normal iterative loop (well, all "normal" loops are per definition iterative, right?) could already be sufficient. The matter is that scome code tends to be called over and over, virtually endlessly, which puts some reference (e.g. variable or function pointer) on the stack. Often it's recursive code causing such behavior but not always.

Anyways, as already said: check the loops in the scripts in question, maybe add some console log output to them and try to figure out what they do.
  22:20:20  7 March 2012
profilee-mailreply Message URLTo the Top
Lijenstina
Doom metal in the shade of the flying radiators
(Resident)

 

 
On forum: 07/23/2005
 

Message edited by:
Lijenstina
03/07/2012 22:22:16
Messages: 1902
I'll start with all the mods that have an update in real time. Slow regeneration, atmen I know do have them for the rest I haven't got them installed.
Unknown command: nil is most likely a printf, logf or any other function that has an console text output of a variable - that variable tested is nil - most likely a debug left in. Do a search in the scripts You've merged for those debug function calls and comment them.

One way of testing is to isolate the culprit. Disable one mod per time by commenting out the calls in bind_stalker for them or any script that has being used as the "main hub" for the calls. If the ctds continue disable an another one until they stop. Then when you have isolated the culprit first look if you have merge it correctly - check calls to other functions, sections items needed etc. If it is merged correctly then it could be a mod conflict or a logical error in the merged mod. Both needs some knowledge of lua and lua implementation in stalker so it isn't that easy.
  23:55:18  7 March 2012
profilee-mailreply Message URLTo the Top
Llynix
(Novice)
 
On forum: 12/19/2011
Messages: 47
Thanks for all the replies. I'll try commenting out stuff from bind_stalker first and see if it helps.
  11:40:11  8 March 2012
profilee-mailreply Message URLTo the Top
Llynix
(Novice)
 
On forum: 12/19/2011
Messages: 47
It seems Singapur22s Artefact Detector mod was producing the "unknown command: nil" and most probably the stack overflow. Perhaps I didn't implement it into bind.stalker correctly.
  14:16:08  8 March 2012
profilee-mailreply Message URLTo the Top
Llynix
(Novice)
 
On forum: 12/19/2011
Messages: 47
I belive the bind_belt.script from the artefact detector mod is causing the CTDs. I played for a couple of hours without the detector mod and had no problems.

So, again, the script is producing an "Unknown command: nil" message in the console log each time I close the inventory, a box or a trader screen. This happens not only in my mod, but in the Vanilla game with the artrfact detector mod as well. I believe the messages keep showing up and eventually lead to the stack overflow.

Then again, I belive there are people on this forum who use this mod and have no problems. Could anyone take a quick look at this script and see if there's anything wrong with it that could cause the "unknown command: nil" message?

The version of the artefact detector mod I'm using is 1.0, the only one I could find. I found it through this thread: https://gsc-game.com/index.php?t=community&s=forums&s_game_type=xr&thm_page=3&thm_id=20594&page=1&sort=ASC&sec_id=16

MrSeyker seems to have updated the mod somehow, perhaps he has a fully working version? I really like when the artefacts in the game are invisible. The detector idea also adds a lot of realism and atmosphere to the game IMHO. I'd appreciate any help.

[pre]- ================================================ ==========================
- == Script defining a list of items on the belt of the actor
- == The list is stored in a table db.belt
- == Author: Singapur22
- == Last Modified: August 23, 2010
- ================================================ ==========================

local separator = nil - / / variable to store userdata separator
local del_separator = false - / / remove the key separator
local start_add_belt = false - / / start filling in the key table db.belt
local open_inventory = false - / / the key opening / closing inventory
local stop_update = false
local start_function = true

- The main function of iteration inventory
- (Linked to the function update () in file bind_stalker.script)
function IterateInventory ()
if stop_update == true then return end

- / / Delete all the stored randomly separators (made at boot / reboot script)
if start_function then
db.actor: inventory_for_each (function (item)
if item: section () == "separator" then
alife (): release (item, true)
end
end)
separator = nil
del_separator = false
start_function = false
end

- / / Remove the delimiter (third cycle)
if del_separator and separator then
this.DeleteSeparator ()
stop_update = true
hud_detector.initialise_det ()
return
end

- / / Iteration of the inventory (second cycle)
if separator then
db.belt = {}
db.actor: inventory_for_each (ScanInventory)
del_separator = true
start_add_belt = false
else
- / / Spawn a separator (first cycle)
separator = alife (): create ("separator", db.actor: position (), db.actor: level_vertex_id (), db.actor: game_vertex_id (), db.actor: id ())
end
end

- Deleting a separator
function DeleteSeparator ()
alife (): release (separator, true)
separator = nil
del_separator = false
end

- Function scan equipment
function ScanInventory (item)
local section = item: section ()

if start_add_belt and not DetermineSlot (item: id ()) then
db.belt [section] = (not db.belt [section] and a) or (db.belt [section] + 1)
end

if item: section () == "separator" then
start_add_belt = true
end
end

- Function definitions bind the object to one of the slots
function DetermineSlot (item_id)
for i = 0, 12 do
local obj = db.actor: item_in_slot (i)
if obj and obj: id () == item_id then
return true
end
end
return false
end

- Start function table is updated at the close of stock
- (Tied to kolbeku info_callback () in file bind_stalker.script)
function InventoryInfo (info)
if info == "ui_inventory" or info == "ui_car_body" or info == "ui_trade" then
open_inventory = true
if separator then
this.DeleteSeparator ()
end
elseif info == "ui_inventory_hide" or info == "ui_car_body_hide" or info == "ui_trade_hide" then
open_inventory = false
stop_update = false
end
end[/pre]
  04:20:54  10 March 2012
profilee-mailreply Message URLTo the Top
NatVac
Senior Resident
 

 
On forum: 06/15/2007
Messages: 4302
>> - The main function of iteration inventory
>> - (Linked to the function update () in file bind_stalker.script)

Really?

You are iterating over your inventory in your actor_binder:update() loop?

<*brain 'splodes*>

Extending Lijenstina: Also look for get_console():execute() statements with arguments that might possibly evaluate to "nil" (string). Start by looking for execute() statements with the word "console" nearby.
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2022 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.