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

gcc14: Latest 1.26.2 release failed to build on fedora rawhide #603

Closed
raveit65 opened this issue Jan 24, 2024 · 8 comments · Fixed by #604
Closed

gcc14: Latest 1.26.2 release failed to build on fedora rawhide #603

raveit65 opened this issue Jan 24, 2024 · 8 comments · Fixed by #604

Comments

@raveit65
Copy link
Member

raveit65 commented Jan 24, 2024

Expected behaviour

Succesful build on fedora rawhide

Actual behaviour

Latest 1.26.2 release failed to build on fedora rawhide

Steps to reproduce the behaviour

Latest 1.26.2 release failed to build on fedora rawhide.
from https://kojipkgs.fedoraproject.org//work/tasks/8848/112258848/build.log

epub-document.c: In function 'check_mime_type':
epub-document.c:635:40: error: passing argument 1 of 'g_strv_length' from incompatible pointer type [-Wincompatible-pointer-types]
  635 |         for (i = 0; i < g_strv_length (mimetypes); i++) {
      |                                        ^~~~~~~~~
      |                                        |
      |                                        const gchar ** {aka const char **}
In file included from /usr/include/glib-2.0/glib/gstring.h:37,
                 from /usr/include/glib-2.0/glib/giochannel.h:36,
                 from /usr/include/glib-2.0/glib.h:56,
                 from /usr/include/glib-2.0/glib/gi18n-lib.h:23:
/usr/include/glib-2.0/glib/gstrfuncs.h:383:55: note: expected 'gchar **' {aka 'char **'} but argument is of type 'const gchar **' {aka 'const char **'}
  383 | guint                 g_strv_length    (gchar       **str_array);
      |                                         ~~~~~~~~~~~~~~^~~~~~~~~
epub-document.c:646:48: error: passing argument 1 of 'g_strv_length' from incompatible pointer type [-Wincompatible-pointer-types]
  646 |                 for (i = 0; i < g_strv_length (mimetypes); i++) {
      |                                                ^~~~~~~~~
      |                                                |
      |                                                const gchar ** {aka const char **}
/usr/include/glib-2.0/glib/gstrfuncs.h:383:55: note: expected 'gchar **' {aka 'char **'} but argument is of type 'const gchar **' {aka 'const char **'}
  383 | guint                 g_strv_length    (gchar       **str_array);
      |                                         ~~~~~~~~~~~~~~^~~~~~~~~
make[4]: *** [Makefile:640: epub-document.lo] Error 1

For some reason the build warning will be treat as error in rawhide, but i have to deal with it.
The warning is caused by this commit 39ba86c
PR was without CI and build logs !
#571
In 1.26 branch we see the warnings in travis-ci logs https://app.travis-ci.com/github/mate-desktop/atril/jobs/601205067#L1813
Reverting that commit clearly removes the warnings.
Locally i fixed the warnings like this.

From 50387a241185322dee52f5a6aeca84db82679601 Mon Sep 17 00:00:00 2001
From: raveit65 <mate@raveit.de>
Date: Wed, 24 Jan 2024 19:45:24 +0100
Subject: [PATCH] fix a build warning

---
 backend/epub/epub-document.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c
index 3ea7bdaa..48eb42de 100644
--- a/backend/epub/epub-document.c
+++ b/backend/epub/epub-document.c
@@ -632,7 +632,7 @@ check_mime_type(const gchar* uri,GError** error)
         const gchar* mimetypes[] = {"application/epub+zip", "application/x-booki+zip", NULL};
         guint i;
 
-        for (i = 0; i < g_strv_length (mimetypes); i++) {
+        for (i = 0; i < g_strv_length ((gchar**) mimetypes); i++) {
            if (strcmp(mimeFromFile, mimetypes[i]) == 0)
                 return TRUE;
         }
@@ -643,7 +643,7 @@ check_mime_type(const gchar* uri,GError** error)
             mimeFromFile = ev_file_get_mime_type (uri, TRUE, &err);
             if (mimeFromFile)
             {
-                for (i = 0; i < g_strv_length (mimetypes); i++) {
+                for (i = 0; i < g_strv_length ((gchar**) mimetypes); i++) {
                     if (g_strcmp0(mimeFromFile, mimetypes[i]) == 0)
                         return TRUE;
                 }
-- 
2.43.0

@cwendling @mate-desktop/core-team
Is this a valid fix?
If yes , i will create a PR.

MATE general version

1.26

Package version

1.26.2

Linux Distribution

Fedora rawhide

Link to bugreport of your Distribution (requirement)

I do not file out report against myself

@raveit65 raveit65 changed the title Latest 1.26.2 release failed to build on fedora rawhide gcc14: Latest 1.26.2 release failed to build on fedora rawhide Jan 25, 2024
@raveit65
Copy link
Member Author

raveit65 commented Jan 26, 2024

I checked building all packages with gcc14 for fedora rawhide and i could fix most packages. Only atril failed to build because of -Wincompatible-pointer-types warning which is treat as an error with gcc14.
@cwendling @mate-desktop/core-team
Can you please take a look at it?

@raveit65
Copy link
Member Author

raveit65 commented Jan 30, 2024

I got a FTBFS from Fedora Release Engineering group.
Atril will be removed from fedora when we don't fix the build warning.
https://bugzilla.redhat.com/show_bug.cgi?id=2260996
Sorry, i don't have the knowledge to fix it.
Please help.
@zhuyaliang @lukefromdc @cwendling @yetist @mate-desktop/core-team

@lukefromdc
Copy link
Member

lukefromdc commented Jan 30, 2024

I do not have gcc 14 yet on Debian Unstable, but the warnings from the logs are a conflict between gchar and const gchar in lines 637 and 648 of epub-document.c

/usr/include/glib-2.0/glib/gstrfuncs.h:383:55: note: expected 'gchar **' {aka 'char **'} but argument is of type 'const gchar **' {aka 'const char **'}
383 | guint g_strv_length (gchar **str_array);

changing line 632 from
const gchar* mimetypes[] = {"application/epub+zip", "application/x-booki+zip", NULL};
to
gchar* mimetypes[] = {"application/epub+zip", "application/x-booki+zip", NULL};

stops the build warnings and (on gcc 13 anyway) the build now completes. Runtime behavior same as before, note that under wayland opening epubs fails with a warning about not being able to create an OpenGL context on that backend.

We still get these build warnings, unchanged either way. No idea if these also shut down a gcc 14 build though:


In function 'setup_document_content_list',
    inlined from 'epub_document_load' at epub-document.c:1771:34:
epub-document.c:1048:26: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'unsigned char[8]' [-Warray-bounds=]
 1048 |             newnode->key = (gchar*)xml_get_data_from_node(itemrefptr,XML_ATTRIBUTE,(xmlChar*)"idref");
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
epub-document.c:1047:40: note: object of size 8 allocated by 'g_malloc0'
 1047 |             contentListNode *newnode = g_malloc0(sizeof(newnode));
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
epub-document.c:1064:32: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'contentListNode[0]' {aka 'struct _contentListNode[]'} [-Warray-bounds=]
 1064 |                 g_free (newnode->key);
      |                         ~~~~~~~^~~~~
epub-document.c:1047:40: note: object of size 8 allocated by 'g_malloc0'
 1047 |             contentListNode *newnode = g_malloc0(sizeof(newnode));
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
epub-document.c:1075:28: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'unsigned char[8]' [-Warray-bounds=]
 1075 |             newnode->value = g_filename_to_uri(absolutepath->str,NULL,&err);
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
epub-document.c:1047:40: note: object of size 8 allocated by 'g_malloc0'
 1047 |             contentListNode *newnode = g_malloc0(sizeof(newnode));
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
epub-document.c:1078:25: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'unsigned char[8]' [-Warray-bounds=]
 1078 |             if ( newnode->value == NULL )
      |                  ~~~~~~~^~~~~~~
epub-document.c:1047:40: note: object of size 8 allocated by 'g_malloc0'
 1047 |             contentListNode *newnode = g_malloc0(sizeof(newnode));
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
epub-document.c:1086:28: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'unsigned char[8]' [-Warray-bounds=]
 1086 |             newnode->index = indexcounter++ ;
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
epub-document.c:1047:40: note: object of size 8 allocated by 'g_malloc0'
 1047 |             contentListNode *newnode = g_malloc0(sizeof(newnode));
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
epub-document.c:1080:32: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'contentListNode[0]' {aka 'struct _contentListNode[]'} [-Warray-bounds=]
 1080 |                 g_free (newnode->key);
      |                         ~~~~~~~^~~~~
epub-document.c:1047:40: note: object of size 8 allocated by 'g_malloc0'
 1047 |             contentListNode *newnode = g_malloc0(sizeof(newnode));
      | 

@lukefromdc
Copy link
Member

lukefromdc commented Jan 30, 2024

@raveit65 , your fix also works with (at least with gcc-13), with behavior identical to what I tested. You can open a PR or I can do it, whichever is easier

@correctmost
Copy link
Contributor


In function 'setup_document_content_list',
    inlined from 'epub_document_load' at epub-document.c:1771:34:
epub-document.c:1048:26: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'unsigned char[8]' [-Warray-bounds=]
 1048 |             newnode->key = (gchar*)xml_get_data_from_node(itemrefptr,XML_ATTRIBUTE,(xmlChar*)"idref");

I have a fix for these newnode warnings as part of #600.

@raveit65
Copy link
Member Author

@raveit65 , your fix also works with (at least with gcc-13), with behavior identical to what I tested. You can open a PR or I can do it, whichever is easier

Ok, i will open a PR.

@raveit65
Copy link
Member Author


In function 'setup_document_content_list',
    inlined from 'epub_document_load' at epub-document.c:1771:34:
epub-document.c:1048:26: warning: array subscript 'contentListNode {aka struct _contentListNode}[0]' is partly outside array bounds of 'unsigned char[8]' [-Warray-bounds=]
 1048 |             newnode->key = (gchar*)xml_get_data_from_node(itemrefptr,XML_ATTRIBUTE,(xmlChar*)"idref");

I have a fix for these newnode warnings as part of #600.

Cool, i will test your PR.
Note those warnings will not treat as errors with gcc14, but good have fix them.

@cwendling
Copy link
Member

Note those warnings will not treat as errors with gcc14, but good have fix them.

Ironically enough, those show an actual bad issue, and the blocking incompatible ones don't 🤷

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

Successfully merging a pull request may close this issue.

4 participants