Raised This Month: $32 Target: $400
 8% 

Transaction Handle wiped for no reason


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 12-11-2016 , 14:07   Transaction Handle wiped for no reason
Reply With Quote #1

Minimal test case code:

PHP Code:
    Transaction Txn SQL_CreateTransaction();
    
PrintToChatAll("(1) Transaction Handle: %d"Txn); // fine here
    
    
int AttributeIDs[15]; // Txn is never referenced here
    
int TotalAttribs TF2Attrib_ListDefIndices(WeaponEntityAttributeIDs); // Txn is never referenced here
    
PrintToChatAll("(2) Transaction Handle: %d"Txn); // ...and suddenly Txn is INVALID_HANDLE. WTF? 
Chat printout:

Code:
(1) Transaction Handle: 234029374
(2) Transaction Handle: 0
Logs:

Code:
L 12/11/2016 - 13:54:25: [SM] Exception reported: Invalid handle 0 (error 4)
L 12/11/2016 - 13:54:25: [SM] Blaming: mvm_dropped_weapons.smx
L 12/11/2016 - 13:54:25: [SM] Call stack trace:
L 12/11/2016 - 13:54:25: [SM]   [0] SQL_AddQuery
L 12/11/2016 - 13:54:25: [SM]   [1] Line 519, E:\Servers\Management Tools\Sourcemod Plugins\mvm_dropped_weapons.sp::AddPickedUpWeaponToDatabase
L 12/11/2016 - 13:54:25: [SM]   [2] Line 426, E:\Servers\Management Tools\Sourcemod Plugins\mvm_dropped_weapons.sp::RefineDroppedWeapon
sm_dump_handles showed that the transaction handle still is floating somewhere which suggests this is some memory leak?

Code:
0x0df3013e	mvm_dropped_weapons	Transaction         	-1        // Incidentally, 0x0df3013e	(hex) = 234029374 (decimal)
The workaround that works fine: Call TF2Attributes and then make the transaction.

PHP Code:
    int AttributeIDs[15]; // Txn is never referenced here
    
int TotalAttribs TF2Attrib_ListDefIndices(WeaponEntityAttributeIDs);

    
Transaction Txn SQL_CreateTransaction(); 
But I still want an explanation on why or how the handle got wiped so that this mistake doesn't repeat itself again in the future.

Thanks!

Last edited by Potato Uno; 12-11-2016 at 14:13.
Potato Uno is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 12-11-2016 , 14:17   Re: Transaction Handle wiped for no reason
Reply With Quote #2

This is the relevant code for the TF2Attrib native call

https://github.com/FlaminSarge/tf2at...ibutes.sp#L755
Potato Uno is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-11-2016 , 14:20   Re: Transaction Handle wiped for no reason
Reply With Quote #3

Your plugin:
PHP Code:
int AttributeIDs[15]; 
The native you are calling:
PHP Code:
SetNativeArray(2iAttribIndices16); 
This is why all natives dealing with strings and arrays are meant to take a size param...
__________________
asherkin is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 12-11-2016 , 14:29   Re: Transaction Handle wiped for no reason
Reply With Quote #4

Makes sense, thanks for the explanation!
Potato Uno is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 12-11-2016 , 19:54   Re: Transaction Handle wiped for no reason
Reply With Quote #5

deja vu
Miu is offline
FlaminSarge
Veteran Member
Join Date: Jul 2010
Old 12-11-2016 , 20:00   Re: Transaction Handle wiped for no reason
Reply With Quote #6

rip
Will fix on my end when I get a chance, but the plugin docs DO state that it's size 16, if worded a bit poorly.

@ash would you suggest the return value be at most the max length passed in, or the real number of attributes on the item, so that if the return is larger than the max length passed in, users will know that they have passed in too small a value?
__________________
Bread EOTL GunMettle Invasion Jungle Inferno will break everything. Don't even ask.

All plugins: Randomizer/GiveWeapon, ModelManager, etc.
Post in plugin threads with questions.
Steam is for playing games.
You will be fed to javalia otherwise.
Psyduck likes replays.

Last edited by FlaminSarge; 12-11-2016 at 20:05.
FlaminSarge is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode