Simple handler crashes LC or worse

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Simple handler crashes LC or worse

Post by dunbarx » Sun Jun 07, 2015 2:51 pm

Make a new stack. Make a new field. Put some text into it. Put this into its script:

Code: Select all

on rawKeyDown theKeyNumber
  get word 2 of the selectedChunk
   if theKeyNumber is 65288 then delete char it - 1 of the selectedChunk
end rawKeyDown
Set the cursor in the text somewhere and press backSpace. I can reliable either crash LC , or, now and then, I find that the selectedChunk is copied after the selection. Or both. This came about by accident while fooling around with a handler in a beginners thread query.

I have the stack, and would like someone to either teach me LC or verify the instability OSX 10.9, LC 6.7.4.

Craig Newman
Last edited by dunbarx on Tue Jun 23, 2015 2:21 pm, edited 1 time in total.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Simple handler crashes LC or worse

Post by sturgis » Mon Jun 22, 2015 12:39 am

You're right, It seems the engine doesn't like trying to delete a char from a return value (IE delete char 104 of "char 94 to 93 of field 1") Its trying to delete a char from "the selectedchunk returned string, rather than the field. 7.0.5 spits up too. (though no hard crashes, just compiler errors on run)

I don't actually think it should work, but a more informative and reliable error would be nice.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Simple handler crashes LC or worse

Post by dunbarx » Tue Jun 23, 2015 3:00 pm

Thank you, Sturgis.

I submitted a bug report.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Simple handler crashes LC or worse

Post by FourthWorld » Tue Jun 23, 2015 3:14 pm

Do you get the same result if you use the backSpaceKey message instead of trapping it through rawKeyDown?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Simple handler crashes LC or worse

Post by sturgis » Tue Jun 23, 2015 3:24 pm

As written, it just pian shouldn't work. When everything is resolved it ends up looking like the following:

Code: Select all

delete char 26 of char 12 to 16 of field 1
Or if there is only an insertion point..

Code: Select all

delete char 29 - 1 of char 29 to 28 of field 1


Strangely, now I can't get it to crash, it doesn't actually delete a char but does move the cursor to the beginning of the selection if there is one. Ending with an insertion point and no selection.
(it should just be deleting char 29-1 of field 1 of course.)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Simple handler crashes LC or worse

Post by dunbarx » Tue Jun 23, 2015 3:51 pm

@Richard.

BackSpaceKey message also crashes LC.

@Sturgis. Hmm. I can now crash reliably in two ways, thanks to Richard. I will amend the bug report.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Simple handler crashes LC or worse

Post by FourthWorld » Tue Jun 23, 2015 4:23 pm

What's the bug report ID?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Simple handler crashes LC or worse

Post by dunbarx » Tue Jun 23, 2015 4:41 pm

Richard.
What's the bug report ID?
15539

Craig

Post Reply