OpenCollarTeam / OpenCollar

Other
123 stars 128 forks source link

OC_dialog crashing in V 8.3 when detach is attempted #1119

Open SilkieSabra opened 1 week ago

SilkieSabra commented 1 week ago

In V 8.3, a user wearing quite a few items with long names is crashing oc_dialog when someone tries to open the detach menu from Apps. The rest of the collar is still able to be used. The Detach button in apps stops producing the detach menu and oc_dialog throws the error. https://gyazo.com/2babcc6899f086e1a75ffedf1d7744dc I don't know why the script error is coming from oc_dialog but no doubt there's an explanation -- or why the rest of the collar continues to work after a stack heap message coming from oc_dialog.

Do we need to look at oc_detach?

Here's the list of what this user was wearing. Reducing the number of worn items allowed oc_detach to work and did not produce a script error from oc_dialog.

PKC Queen Bee Bento Rings - Legacy Left {Creator} [R hand] PKC Queen Bee Bento Rings - Legacy Right {Creator} [R hand] / EYES / lel EvoX 3.1 {Creator} [L eye] / HEAD / lel EvoX SIWA 3.1 {Creator} [chin] / TEETH / LeLUTKA 3.1 {Creator} [] AVEC TOI - Wendy O Stilettos (Legacy) {Creator} [pelvis] AVEC TOI - Wendy O Stockings (Legacy) {Creator} [pelvis] Cynful Mina Piercings - Back Dimples L - Legacy F {Creator} [R pectoral] Cynful Mina Piercings - Back Dimples R - Legacy F {Creator} [L pectoral] Cynful Mina Piercings - Belly - Legacy Female {Creator} [stomach] Cynful Mina Piercings - Cleavage - Legacy {Creator} [chest] Cynful Mina Piercings - Collarbone - Legacy Female {Creator} [] Cynful Mina Piercings - Spine - Legacy F {Creator} [back] It's NOT Mine! Complete Body Cum System {Creator} [pelvis] LeLUTKA.Png.SIWA.Ear.Set {Creator} [R ear] MIDNA - Alice Piercing - GIFT {Creator} [L ear] Piercing de nez or et diamant {Creator} [nose] RAWR! Delerium Rings Legacy {Creator} [nose] RAWR! Plumb Armlets Legacy {Creator} [R upper arm] RAWR! Plumb Necklace Legacy {Creator} [neck] S&P Collar Maya (OC) {Creator} [neck] TRUTH / Flirt / Size 2 {Creator} [head] [BODY] Legacy (f) (1.7.1) {Creator} [] [FEET] Legacy (f) (Classic Fit) (1.7.1) {Creator} [] [Glitzz] Xandra Panties - Fatpack - Legacy {Creator} [pelvis] [HANDS] Legacy (f) (1.7.1) {Creator} [L hand] kill the ugly linden body for BOM (add me) {Creator} [R hip] [ ~[LeiMotiv] Missy Dress . Legacy {Creator} [R hand]

NikkiLacrima commented 1 week ago

Tried to add an insane amount of worn items, and for sure oc_dialog gives a stack/heap error when trying to open the Detach app menu. Then there is a bit of reset happening and soon most collar functions are back to normal but trying the access the Detach app crashes the oc_dialog again, and again results in some resetting. This happens until the amount of worn items is reduced.

We have known for a long time that oc_dialog is memory limited and can give stack/heap errors when lots of items with long names are displayed in dialog selections.

oc_detach simply lists whhat is worn, looks ok to me. Cant see any weirdness there.

/Nikki

NikkiLacrima commented 1 week ago

Some more observations about memory in oc_dialog.

It seems that the stack heap collision actually happens in SortUUIDList(), not very surprising as it makes two copies of every item name and one extra copy of every key. So the plan to improve the situation is to make sure to release as much memory as possible before calling SortUUIDList(), this is done in the link_message handler for DIALOG message. The second thing is to tweak the SortUUIDList() function itself. This can be done by using the list index i instead of the key in the list of key,name pairs, this saves 75 bytes per entry, approx 3k. Then not use a separate list of names to sort, use strided sort to sort the list of index,name pairs.

We can get a further reduction of memory footprint if we truncate the item names to say 32 characters before sorting, this might make some names with the first 32 characters equal end up in the wrong order, but that doesnt feel like a big issue, the full names are still used in the actual dialog.

A full PR is worked on, after some more testing. Comments ??

/Nikki