|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Jul 06, 2011 10:01 pm
[BUG] Compiled code tab on variables |
I understand that it is known that going to the compiled code tab on variables will corrupt them (change the contents to a random bit of data from somewhere in your package). Apparently there's nothing that can be done about it, since the issue is with a third-party addon, but I've recently found that the problem actually goes much deeper than losing data in your variable, it will corrupt your package. That's obviously a huge issue, and something has to be done about it.
Steps to reproduce this (note: running CMUD 3.34 on Windows 7 64-bit).
1) Open CMUD. In the sessions window, click new session. Type 'Test' in the title box and click save changes.
2) Right-click the new test session's icon and choose offline.
3) Click settings on the top bar. The contents of the Test.pkg file are displayed, there is just one window (Test). Click new, then click new variable. Type 'testlist' for the name and choose type string list. Click save.
NOTE: At this point, the package (C:/Program Files/CMUD/Test/Test.pkg) is 12 KB.
4) On the command line, run the following code: #50000 {#ADDITEM testlist %i}. In the package editor, click the Test window then back to the testlist variable to refresh the contents. It should contain 50000 items (the numbers from 1 to 50000).
NOTE: At this point, the package (C:/Program Files/CMUD/Test/Test.pkg) is 578 KB.
5) Keeping the testlist variable selected in the package editor, click the compiled code tab, then click the string list tab (if you don't see the tabs, make sure you have show advanced tabs checked under the package editor's view menu).
6) Click the Test window then back to the testlist variable to refresh the contents. The variable is empty. All functions reflect this (#SHOW %item(@testlist,12345) is null, #SHOW %numitems(@testlist) is 0, #FORALL @testlist {#SHOW %i} shows nothing).
It looks like the data is completely gone, lost for good, and the package should have shrunk back to 12 KB. However, it's still 578 KB. If you open the package file in a text editor (I used notepad) you will see that it's still full of numbers, even though CMUD won't read them. I was unable to restore or remove the data.
The easiest fix for this is probably to just remove the compiled code tab entirely from variables. Different settings already have different tabs, so I assume this should be no trouble, and the compiled code tab doesn't really belong there anyway.
Daern |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Jul 08, 2011 4:04 pm |
Confirmed and added to bug list. Not sure what's causing the data to get removed like that, but I'll take a look at it.
On the PKG file issue, that's harder to debug. With an SQL database (PKG file is SQLite database) the data in the database is not removed normally until the database gets purged and flushed. The space in the database is marked to use by new data later but the space is not normally reclaimed...that would make databases really slow if it had to compress the file after deleting data.
You can use an external SQLite program to flush the database and remove the unused data. CMUD won't do that.
The reason the Compiled Code tab is still available is that there are old #USERFUNC variables that actually contain script functions. So it's still useful for debugging in some cases and the Compiled Code tab is only for debugging (which is why it's only visible when you enable advanced tabs).
My guess is that using the JSON tab might also show a similar problem. But I'll check that when I try to fix this bug.
In any case, your entire package file is not corrupted. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Jul 08, 2011 4:52 pm |
Zugg wrote: |
You can use an external SQLite program to flush the database and remove the unused data. CMUD won't do that. |
Well, what do you know, my package is back down to 12 KB. Thanks for that :)
Zugg wrote: |
The reason the Compiled Code tab is still available is that there are old #USERFUNC variables that actually contain script functions. So it's still useful for debugging in some cases and the Compiled Code tab is only for debugging (which is why it's only visible when you enable advanced tabs). |
Perhaps a new variable type could be added for function variables, and the compiled code tab would only show for that type? |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|