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

SegFault when opening a corrupt file (produced by Xournal++ webapp) #5183

Open
Shahin-rmz opened this issue Sep 28, 2023 · 12 comments · May be fixed by #5554
Open

SegFault when opening a corrupt file (produced by Xournal++ webapp) #5183

Shahin-rmz opened this issue Sep 28, 2023 · 12 comments · May be fixed by #5554
Labels
bug confirmed Bug has been reproduced by at least one other person Crash good first issue SegFault

Comments

@Shahin-rmz
Copy link

Shahin-rmz commented Sep 28, 2023

Operating System

Linux

(Linux only) Distribution

Ubuntu 22.04

(Linux only) Desktop Environment

Gnome

(Linux Only) Display Server

X.Org

Installation Method

Snap package

Xournal++ Version

1.2.1

libgtk Version

3.24.38

Bug Description

I have tried to annotate a pdf file with Xournal on my android cell phone, and then open it via xournal app on linux.
I can not make it open, the xournal linux app crashes when I want to open the file of xournal mobile!

Expected Behaviour

open and work the .xopp file!

Steps to Reproduce

  1. open xournal on android,
  2. import a pdf,
  3. annotate it,
  4. save it,
  5. send it via telegram
  6. open it via xournal linux

Additional Context

here is the log of my error:
thanks for help.

Date: Thu Sep 28 20:52:48 2023
Error: signal 11
Xournal++ version 1.2.1
Git commit b48932a2 from xournalpp/HEAD
Gtk version 3.24.38

[bt]: (0) /snap/xournalpp/86/usr/bin/xournalpp(+0x3e3555) [0x55d23f2f3555]
[bt]: (1) /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f92db8eb520]
[bt]: (2) /lib/x86_64-linux-gnu/libc.so.6(+0x198ae2) [0x7f92dba41ae2]
[bt]: (3) /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler10parseBgPdfEv+0x1bc) [0x55d23f32349c]
[bt]: (4) /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler9parsePageEv+0x224) [0x55d23f323ff6]
[bt]: (5) /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler18parserStartElementEP20_GMarkupParseContextPKcPS3_S4_PvPP7_GError+0xc1) [0x55d23f326f1d]
[bt]: (6) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x66967) [0x7f92dc036967]
[bt]: (7) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_markup_parse_context_parse+0x13b6) [0x7f92dc0380f6]
[bt]: (8) /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler8parseXmlEv+0x151) [0x55d23f3214b5]
[bt]: (9) /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler12loadDocumentERKNSt10filesystem7__cxx114pathE+0x9c) [0x55d23f3286fa]
[bt]: (10) /snap/xournalpp/86/usr/bin/xournalpp(_ZN7Control8openFileENSt10filesystem7__cxx114pathEib+0x357) [0x55d23f3fab21]
[bt]: (11) /snap/xournalpp/86/usr/bin/xournalpp(+0x3e9b3f) [0x55d23f2f9b3f]
[bt]: (12) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_closure_invoke+0x16f) [0x7f92dc1412ef]
[bt]: (13) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x2c713) [0x7f92dc157713]
[bt]: (14) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit_valist+0x11bd) [0x7f92dc162a7d]
[bt]: (15) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit+0x93) [0x7f92dc162f23]
[bt]: (16) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0(g_application_register+0x112) [0x7f92dc2b8632]
[bt]: (17) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0(+0xf1a2e) [0x7f92dc2b8a2e]
[bt]: (18) /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0(g_application_run+0x136) [0x7f92dc2b8d86]
[bt]: (19) /snap/xournalpp/86/usr/bin/xournalpp(_ZN11XournalMain3runEiPPc+0x7f0) [0x55d23f2fb6e1]
[bt]: (20) /snap/xournalpp/86/usr/bin/xournalpp(main+0x29) [0x55d23f2f3112]
[bt]: (21) /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f92db8d2d90]
[bt]: (22) /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f92db8d2e40]
[bt]: (23) /snap/xournalpp/86/usr/bin/xournalpp(_start+0x25) [0x55d23f2f3025]


Try to get a better stracktrace...
[bt] #1 /snap/xournalpp/86/usr/bin/xournalpp(+0x3e3cbf) [0x55d23f2f3cbf]
??:0
[bt] #2 /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f92db8eb520]
??:0
[bt] #3 /lib/x86_64-linux-gnu/libc.so.6(+0x198ae2) [0x7f92dba41ae2]
??:0
[bt] #4 /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler10parseBgPdfEv+0x1bc) [0x55d23f32349c]
??:0
[bt] #5 /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler9parsePageEv+0x224) [0x55d23f323ff6]
??:0
[bt] #6 /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler18parserStartElementEP20_GMarkupParseContextPKcPS3_S4_PvPP7_GError+0xc1) [0x55d23f326f1d]
??:0
[bt] #7 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x66967) [0x7f92dc036967]
??:0
[bt] #8 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_markup_parse_context_parse+0x13b6) [0x7f92dc0380f6]
??:0
[bt] #9 /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler8parseXmlEv+0x151) [0x55d23f3214b5]
??:0
[bt] #10 /snap/xournalpp/86/usr/bin/xournalpp(_ZN11LoadHandler12loadDocumentERKNSt10filesystem7__cxx114pathE+0x9c) [0x55d23f3286fa]
??:0
[bt] #11 /snap/xournalpp/86/usr/bin/xournalpp(_ZN7Control8openFileENSt10filesystem7__cxx114pathEib+0x357) [0x55d23f3fab21]
??:0
[bt] #12 /snap/xournalpp/86/usr/bin/xournalpp(+0x3e9b3f) [0x55d23f2f9b3f]
??:0
[bt] #13 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_closure_invoke+0x16f) [0x7f92dc1412ef]
??:0
[bt] #14 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x2c713) [0x7f92dc157713]
??:0
[bt] #15 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit_valist+0x11bd) [0x7f92dc162a7d]
??:0
[bt] #16 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit+0x93) [0x7f92dc162f23]
??:0
[bt] #17 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0(g_application_register+0x112) [0x7f92dc2b8632]
??:0
[bt] #18 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0(+0xf1a2e) [0x7f92dc2b8a2e]
??:0
[bt] #19 /snap/xournalpp/86/gnome-platform/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0(g_application_run+0x136) [0x7f92dc2b8d86]
??:0
[bt] #20 /snap/xournalpp/86/usr/bin/xournalpp(_ZN11XournalMain3runEiPPc+0x7f0) [0x55d23f2fb6e1]
??:0
[bt] #21 /snap/xournalpp/86/usr/bin/xournalpp(main+0x29) [0x55d23f2f3112]
??:0
[bt] #22 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f92db8d2d90]
??:0
[bt] #23 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f92db8d2e40]
??:0
[bt] #24 /snap/xournalpp/86/usr/bin/xournalpp(_start+0x25) [0x55d23f2f3025]
??:0


Execution log:

DEBUG   : GLib-GIO :: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
DEBUG   : GLib-GIO :: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
DEBUG   : GLib :: unsetenv() is not thread-safe and should not be used after threads are created
MESSAGE : xopp :: TEXTDOMAINDIR = /snap/xournalpp/86/usr/share/locale, Platform-specific locale dir = /usr/share/xournalpp/../locale, chosen directory = /snap/xournalpp/86/usr/share/locale
INFO    : xopp :: Loading plugins from: /snap/xournalpp/86/usr/share/xournalpp/plugins
INFO    : xopp :: Loading plugins from: /home/shahin/snap/xournalpp/86/.config/xournalpp/plugins
MESSAGE : xopp :: Plugin "MigrateFontSizes" UI initialized
WARNING : xopp :: Parser: attribute domain not found!
WARNING : xopp :: [Crash Handler] Crashed with signal 11
WARNING : xopp :: [Crash Handler] Wrote crash log to: /home/shahin/snap/xournalpp/common/.cache/xournalpp/errorlogs/errorlog.20230928-205248.log
@Shahin-rmz Shahin-rmz added the bug label Sep 28, 2023
@rolandlo
Copy link
Member

It looks like xournalpp_mobile produced an invalid .xopp-file. Maybe we can repair the .xopp-file for you if you provide it. The bug most probably has to be fixed in xournalpp_mobile. Be warned that the (single) developer of xournalpp_mobile appears to be unreachable.

@Shahin-rmz
Copy link
Author

Thanks for quick reply.
You are right, the mobile app does not seem to be stable one.
Is there any alternative apps on android that can easily communicate with Xournal Linux?

PS. in order to be able to send the file, I have changed the name of it from .xopp to .pdf, please rename it again to .xopp file to investigate it.

Der Rundfunkbeitrag - Meldedaten.pdf.txt

@rolandlo
Copy link
Member

The issue is as reported in the Terminal:

(com.github.xournalpp.xournalpp:70753): xopp-WARNING **: 21:34:09.296: Parser: attribute domain not found!

When specifying the PDF background the attribute domain (e.g. domain="absolute") must be provided.

So instead of

<background type="pdf" pageno="0" filename="/data/user/0/online.xournal.mobile/cache/file_picker/Der Rundfunkbeitrag - Meldedaten.pdf"/>

it should be

<background type="pdf" pageno="0" domain="absolute" filename="/data/user/0/online.xournal.mobile/cache/file_picker/Der Rundfunkbeitrag - Meldedaten.pdf"/>

The content doesn't look of interest though. You had only 1 page, didn't you?

@Shahin-rmz
Copy link
Author

The content doesn't look of interest though. You had only 1 page, didn't you?

correct.
I had only 1 page pdf!

@rolandlo
Copy link
Member

I have also noticed that the only page got pageno=0. Counting should start with 1 for pages.

Unfortunately I don't know of a better software on Android to handle .xopp-files.

@Shahin-rmz
Copy link
Author

I have also noticed that the only page got pageno=0. Counting should start with 1 for pages.

Unfortunately I don't know of a better software on Android to handle .xopp-files.

Thanks so much for your time by the way.
How sad...

@bhennion bhennion changed the title Can not open Xournal android app on Xournal Linux SegFault when opening a corrupt file (produced by Xournal++ webapp) Sep 29, 2023
@bhennion bhennion added good first issue Crash confirmed Bug has been reproduced by at least one other person SegFault labels Sep 29, 2023
@bhennion
Copy link
Contributor

We can't do anything about the Android webapp, however we have to fix the SegFault and report the corrupted file to the user.

@tmoerschell
Copy link
Contributor

What should the behavior on this be? Default to "absolute" domain?
The culprit is here: since "domain" is not found, LoadHandlerHelper::getAttrib() returns nullptr, and strcmp() throws the segmentation fault.

const char* domain = LoadHandlerHelper::getAttrib("domain", false, this);
{
const char* sFilename = LoadHandlerHelper::getAttrib("filename", false, this);
if (sFilename == nullptr) {
error("PDF Filename missing!");
return;
}
pdfFilename = fs::u8path(sFilename);
}
if (!strcmp("absolute", domain)) // Absolute OR relative path

There is at least a duplicate in LoadHandler::parseBgPixmap(), and a few other attributes that are passed to strcmp() without checking for nullptr

@bhennion
Copy link
Contributor

We should report an error.

Someone could also implement a "Repare file" functionality, but that's beyond this ticket I think.

@rolandlo
Copy link
Member

I have opened an issue on the xournalpp_mobile issue tracker https://gitlab.com/TheOneWithTheBraid/xournalpp_mobile/-/issues/58.

@rolandlo
Copy link
Member

What should the behavior on this be? Default to "absolute" domain? The culprit is here: since "domain" is not found, LoadHandlerHelper::getAttrib() returns nullptr, and strcmp() throws the segmentation fault.

Yes, we must make "absolute" the default domain, otherwise we can't fix this issue from our side.

@tmoerschell
Copy link
Contributor

I'm not sure to understand how everything works in this file parsing. I have a "hot fix" for this issue and a few other similar code places, but it's not pretty, consistent, interactive with the user, or whatever. It just shouldn't throw a segfault right away. See https://github.com/tmoerschell/xournalpp/tree/fix-load-handler-segfaults.
It's probably not any good for a PR, and I don't think I have a good enough knowledge of the parsing system to know what should be done for every single attribute (default to some value, ignore the corresponding code, flat out abort...). So I don't feel comfortable doing a proper fix for this without any further guidance.

@tmoerschell tmoerschell linked a pull request Mar 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed Bug has been reproduced by at least one other person Crash good first issue SegFault
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants