Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin Numbered Bookmarks activated causes geany to crash at start-up #301

Closed
peter-scholtens opened this issue Nov 9, 2015 · 4 comments · Fixed by #306
Closed

plugin Numbered Bookmarks activated causes geany to crash at start-up #301

peter-scholtens opened this issue Nov 9, 2015 · 4 comments · Fixed by #306

Comments

@peter-scholtens
Copy link
Contributor

When the plugin Numbered Bookmarks is switched on, Geany crashes instantly on start-up. Running GDB shows the following warning:

Program received signal SIGSEGV, Segmentation fault.
0x00007fffd153f2f4 in SetMarker (sci=0x9fa4a0, bookmarkNumber=1, markerNumber=2, line=247) at geanynumberedbookmarks.c:885
885 fd=GetFileData(document_get_current()->file_name);

I assume that at start-up the call document_get_current() will return a NULL pointer? And asking a file_name member will cause a segfault?

Tested on geany-plugins commit 4c11373 of Nov. 8th, 2015.

@frlan
Copy link
Member

frlan commented Nov 9, 2015

Something like this could solve the issue:

@@ -874,6 +874,7 @@ static gint NextFreeMarker(ScintillaObject* sci)
 static void SetMarker(ScintillaObject* sci,gint bookmarkNumber,gint markerNumber,gint line)
 {
        guint32 *markers;
 static void SetMarker(ScintillaObject* sci,gint bookmarkNumber,gint markerNumber,gint line)
 {
        guint32 *markers;
+       GeanyDocument *doc;
        FileData *fd;

        /* insert new marker */
@@ -882,6 +883,10 @@ static void SetMarker(ScintillaObject* sci,gint bookmarkNumber,gint markerNumber
        scintilla_send_message(sci,SCI_MARKERADD,line,markerNumber);

        /* update record of which bookmark uses which marker */
+
+       doc = document_get_current();
+       g_return_if_fail(doc != NULL);

but I doubt that this will be without side effect.

@peter-scholtens
Copy link
Contributor Author

I see no side effects, except the signal of the failing assertion:
** (geany:21329): CRITICAL **: SetMarker: assertion 'doc != NULL' failed

Weirdly enough, it depends on the project I select to load into geany: either no problem occurs or it crashes (or reports the warning signal when the above path is applied).

@frlan
Copy link
Member

frlan commented Nov 9, 2015

I could imagine this is caused by some timing. And in fact, the usage of the current document is not very good.

@codebrainz
Copy link
Member

Aside from passing the GeanyDocument instead of the ScintillaObject, and getting to the sci pointer through doc->editor->sci or whatever, there's also a (non public) function document_find_by_sci that could be used to find the document for the scintilla widget (if it was in plugin API).

b4n added a commit to b4n/geany-plugins that referenced this issue Nov 12, 2015
Pass the document pointer instead of always getting the current
document, which may or may not be the one we're working on.

Closes geany#301.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants