After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 323845 - Strange note linking behavior adds note links to wrong words
Strange note linking behavior adds note links to wrong words
Status: RESOLVED FIXED
Product: tomboy
Classification: Applications
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Tomboy Maintainers
Tomboy Maintainers
: 441215 494796 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-12-12 07:27 UTC by Scott Purcell
Modified: 2009-04-23 02:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot of the strange linking behavior (33.71 KB, image/png)
2007-02-02 23:32 UTC, Boyd Timothy
  Details
Checks for hit==NULL in HighlightInBlock (895 bytes, patch)
2009-01-30 16:44 UTC, Florian Pinault
none Details | Review
Checks validity of links before highlighting (1.19 KB, patch)
2009-02-02 10:32 UTC, Florian Pinault
committed Details | Review

Description Scott Purcell 2005-12-12 07:27:21 UTC
Version details: 0.3.2 (Linspire 5.0, Click-n-run)
Distribution/Version: Linspire 5.0

I first attempted to paste the following text into a note:

-----Start Clip ---
TCP Wrappers
For more information, “TCP Wrappers and xinetd” in RH Ref. Guide, man
hosts_options, man 5 hosts_access, /usr/share/doc/tcp_wrappers-<ver>/, 

Package name: tcp_wrappers
Installed by default

Config files: /etc/hosts.allow and /etc/hosts.deny.
Each file must end with a blank line.
Changes take effect immediately – no need to restart services.

<daemon list>: <client list> [: <option>: <option>: ...]

hosts.allow is parsed first and has precedence.  Processing stops at the first
matching rule.  If no rule matches, access is allowed.

Services secured by TCP Wrappers include sshd, sendmail, and all xinetd services

Set a connection banner with a file that can live anywhere, but that must have
the same name as the service it is for.  For example, a banner for vsftpd could
be /etc/banners/vsftpd. A line in /etc/hosts.allow that would enable such a
banner is: 
	vsftpd : ALL : banners /etc/banners/
-----End Clip -----

Each time I pasted, Tomboy closed completely (crashed?).

Next, I attempted to recreate the note by typing the exact same content.  As
soon as I typed "restart" on line 10, the crash repeated itself.  This behaviour
was consistent.  If I replace "restart" with "reload", the rest of the note
would work.
Comment 1 Scott Purcell 2005-12-12 07:46:52 UTC
Verified that this happens on other notes as well.  Tried another note with
different content (but including the word "restart" in another context) with the
same effect.
Comment 2 Rasmus Dietrich 2005-12-18 12:54:12 UTC
I seem to have the same problem, so I'm not opening a new bug.

Version: 0.3.3-2ubuntu1~breezy1

The crash occoured wenn entering "opportuni": as soon as I tiped the "i" Tomboy crashed. I had a link to "Uni" in my "Start Here" note. Changing the Name of that link to something other (Universität) solved the problem for me.
Tiping "oportuni" didn't cause the crash.

Starting Tomboy from terminal with "mono --debug" I got the following backtrace:


Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
in <0x000a5> Tomboy.NoteLinkWatcher+Highlighter:TitleFound (System.String haystack, Int32 start_idx, System.Object value)
in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_string_int_object (string,int,object)
in <0x000e2> Tomboy.TrieTree:FindMatches (System.String haystack, Tomboy.MatchHandler match_handler)
in <0x000ba> Tomboy.NoteLinkWatcher+Highlighter:HighlightTrie (Tomboy.Note note, TextIter start, TextIter end, Tomboy.TrieTree trie)
in <0x000a3> Tomboy.NoteLinkWatcher:HighlightInBlock (TextIter start, TextIter end)
in <0x0010b> Tomboy.NoteLinkWatcher:OnInsertText (System.Object sender, Gtk.InsertTextArgs args)
in <0x00000> <unknown method>
in (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[])
in <0x0006f> System.Reflection.MonoMethod:Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)--- End of inner exception stack trace ---

in <0x00104> System.Reflection.MonoMethod:Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
in <0x00017> System.Reflection.MethodBase:Invoke (System.Object obj, System.Object[] parameters)
in <0x000b3> System.Delegate:DynamicInvokeImpl (System.Object[] args)
in <0x00028> System.MulticastDelegate:DynamicInvokeImpl (System.Object[] args)
in <0x0000e> System.Delegate:DynamicInvoke (System.Object[] args)
in <0x001af> GtkSharp.voidObjectTextIterstringintSignal:voidObjectTextIterstringintCallback (IntPtr arg0, Gtk.TextIter arg1, System.String arg2, Int32 arg3, Int32 key)
in (wrapper native-to-managed) GtkSharp.voidObjectTextIterstringintSignal:voidObjectTextIterstringintCallback (intptr,Gtk.TextIter&,intptr,int,int)
in <0x00000> <unknown method>
in (wrapper managed-to-native) Gtk.Application:gtk_main ()
in <0x00007> Gtk.Application:Run ()
in <0x00007> Gnome.Program:Run ()
in <0x00036> Tomboy.Tomboy:StartTrayIcon ()
in <0x000d8> Tomboy.Tomboy:Main (System.String[] args)
Comment 3 Rasmus Dietrich 2005-12-18 14:21:57 UTC
With the latest CVS version from today, under the same conditions, "Uni" on "Start Here" and writing "opportuni", it no longer crashes, but creates a Note called "opportuni" stating there were a matching note named that way.

Matching Note title 'opportuni' at 493-502...

But there was no note called that way before I wrote "opportuni"...

So the crash ist solved in CVS, but it still does weird things :)
Comment 4 Boyd Timothy 2007-01-04 19:05:05 UTC
Changing the severity of this bug from critical to normal since crashing does not occur anymore.  Perhaps we should close this bug and open a new one to describe the other weird things that are going on.

I just did the following and got weird behavior:

1. Create a note titled "Uni"
2. Create another note "Other Note"
3. In "Other Note", type "auni buni cuni duni euni funi guni ... zuni"

"auni" and "buni" will be marked as active links to other notes.  When clicked on, they do not open the "Uni" note, but new notes titled "auni" and "buni" are created.  "cuni", "duni", etc. are not marked as links.
Comment 5 Boyd Timothy 2007-02-02 23:32:24 UTC
Created attachment 81797 [details]
Screenshot of the strange linking behavior
Comment 6 Tommi Asiala 2007-08-29 16:35:17 UTC
I'm using 0.7.3 and I can't reproduce any of the problems said on this bug. I think this bug should closed.
Comment 7 Boyd Timothy 2007-08-29 21:37:20 UTC
The strange linking behavior still exists, but the crashing doesn't occur anymore.  I've renamed the bug summary.
Comment 8 Boyd Timothy 2008-02-26 19:14:55 UTC
Setting the default assignee and QA Contact to "tomboy-maint@gnome.bugs".
Comment 9 Florian Pinault 2009-01-30 14:40:41 UTC
I also experience this strange behaviour of linking words to non-existing notes.

I have found some explanation :

The bug seems to be in "Manager.TitleTrie.FindMatches"
which returns sometimes a hit pointing to NULL (causing tomboy to wrongly generate a link)

I checked this and added a test :
  if (hit.Value != NULL)
it fixed my problem.

in file watcher.cs : 
void HighlightInBlock (Gtk.TextIter start, Gtk.TextIter end)
{
	ArrayList hits = Manager.TitleTrie.FindMatches (start.GetSlice (end));
	foreach (TrieHit hit in hits) {
		if (hit.Value != null) { // ADDED
			DoHighlight (hit, start, end);
		} // ADDED
	}
}

I worked on the svn version Version 0.13.2, checked out 2009-01-12 15:52.
Comment 10 Sandy Armstrong 2009-01-30 14:55:17 UTC
florian, this code has changed a bit since 0.13.2.  Please try latest SVN, and if you still experience a bug, submit a new patch following these instructions:

http://live.gnome.org/Tomboy/HowToSubmitPatches

One last thing; when you check out from SVN, the version number is not that useful.  Instead, use "svn info" from the top of your checkout to get the "Last Changed Rev".

Thanks!
Comment 11 Florian Pinault 2009-01-30 16:44:23 UTC
Created attachment 127555 [details] [review]
Checks for hit==NULL in HighlightInBlock

The patch submitted test variable 'hit' in NULL value in HighlightInBlock and writes an error log instead of generating fake note links.
This is a work-around, the real bug seems to be in "Manager.TitleTrie.FindMatches" who gives NULL pointeur.
Comment 12 Sandy Armstrong 2009-01-31 08:38:00 UTC
florian, your patch doesn't seem to fix the "auni buni cuni" problem described in comment #4.

What set of steps should I use to test your patch?
Comment 13 Florian Pinault 2009-02-02 08:54:50 UTC
Indeed, the patch doesn't fix the "auni buni cuni" problem described
in comment #4.

The patch fixes the following problem :
When I type the word "voir" or "par" or some others,
a link is created to non-existing note (and hit.value == null).

As for testing the patch, I don't know how to reproduce this problem with a set of notes other than mine, sorry.

I don't think my patch should be included, "Manager.TitleTrie.FindMatches" should be investigated instead.
Comment 14 Florian Pinault 2009-02-02 10:32:25 UTC
Created attachment 127754 [details] [review]
Checks validity of links before highlighting

I think this is a little better :

This patch checks the links in Watchers::DoHighlight before highlighting them, checks for null pointer, and hit pointing to non-existing or wrong notes.

This patch fixes the "auni buni cuni" problem described in
<a href="show_bug.cgi?id=323845#c4">comment #4</a>. 

To test it : see comment #4.

I worked on last rev 2318.
Comment 15 Sandy Armstrong 2009-02-02 17:57:07 UTC
florian, thanks for the updated patch. I didnt' have time to review it before today's release, but I will look at it for the next one.
Comment 16 Sandy Armstrong 2009-02-16 18:30:54 UTC
Florian, this patch seems to work great, and also fixes bug #531085 (for note links, at least).

I'm going to spend a little time playing with it to make sure we don't break any corner cases with it.  Can I have your full name so I can properly credit you for this?
Comment 17 Sandy Armstrong 2009-02-16 22:05:07 UTC
Committed in r2348. Thanks Florian!
Comment 18 Benjamin Podszun 2009-02-17 00:49:52 UTC
*** Bug 441215 has been marked as a duplicate of this bug. ***
Comment 19 Sandy Armstrong 2009-02-17 15:33:29 UTC
*** Bug 494796 has been marked as a duplicate of this bug. ***
Comment 20 Florian Pinault 2009-03-02 09:31:22 UTC
Wouah ! Cool, that's the first time my code will be actually used in a open project !
(my full name is Florian Pinault)