Bug 265145 - Kate crash when writing a "let (...) in" block using Haskell-mode
Summary: Kate crash when writing a "let (...) in" block using Haskell-mode
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: syntax (show other bugs)
Version: SVN
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 269205 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-02-02 00:06 UTC by Ruben Astudillo
Modified: 2011-03-23 13:34 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Text that makes Kate crash (296 bytes, text/plain)
2011-02-02 00:06 UTC, Ruben Astudillo
Details
Quick (and possibly dirty) fix (331 bytes, patch)
2011-02-16 13:05 UTC, jakub.jarozek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ruben Astudillo 2011-02-02 00:06:56 UTC
Created attachment 56770 [details]
Text that makes Kate crash

Version:           SVN (using KDE 4.6.0) 
OS:                Linux

before start i apologize for my English.

on Kate 3.6 and KDE SC 4.6 while writing in the Haskell-mode a "let in" block, the main windows goes unusable using 100% of a core, this happens specifically at the end of the "let" line when you press enter

Reproducible: Always

Steps to Reproduce:
1. Open Kate and select Haskell from the Tools -> Mode -> Source Code -> Haskell (I'm translating from the Spanish options were it is "Herramientas -> Modo -> Codigo fuente -> Haskell

2. Copy and paste the following code, (also i am uploading as an attachment)

--------------------------------------------------------------
elementAt :: [a] -> Int -> a
elemenAt xs num = let halp :: [a] -> Int -> Int -> a
		      halp (x:xs) num meta = if (num /= meta) 
                                             then (halp xs (num + 1) meta) 
                                             else (head xs) 
		  in (halp xs 1 num)

----------------------------------------------------------------------

3. Put the cursor at the end of the second line (the one with the "let" word on it) and press enter, it should trigger the bug

Actual Results:  
the Gui goes unusable ,and the process start using 100% of a core 

Expected Results:  
it should only start a new line
Comment 1 Andrius 2011-02-02 02:53:19 UTC
Confirmed, also on win32.
Comment 2 Erlend Hamberg 2011-02-02 15:23:08 UTC
this must be a bug in `kde4-config --prefix`/share/kde4/apps/katepart/script/haskell.js. maybe a loop that's running wild?

i'm away until 14 february and won't be able to look at this until after i'm back. if any of you want to look at it, run “kdebugdialog” and enable debug output from “13050 kate (scripts)” and then enable debugging in the js file by setting debugMode to true in line 12. this should help pin-point the problematic area in the file.

if you are able to fix it, please attach an updated version of haskell.js. :-)
Comment 3 jakub.jarozek 2011-02-16 13:05:06 UTC
Created attachment 57292 [details]
Quick (and possibly dirty) fix

The loop at line 187 goes infinte.
A quick hack: adding check for positive line number fixes it :)
but I'm not sure if that was the only cause of this problem...
Comment 4 Erlend Hamberg 2011-02-28 21:14:48 UTC
Git commit d11f5b173ff3640b7587cdd79297957d544f8312 by Erlend Hamberg.
Committed on 28/02/2011 at 21:07.
Pushed by ehamberg into branch 'master'.

fix crash in haskell indenter

when searching for a ���do���, the search could go above line 1. thanks to
Jakub Jar����ek for the patch.

BUG: 265145

M  +3    -2    part/script/data/haskell.js     

http://commits.kde.org/kate/d11f5b173ff3640b7587cdd79297957d544f8312
Comment 5 Erlend Hamberg 2011-03-23 13:34:54 UTC
*** Bug 269205 has been marked as a duplicate of this bug. ***