Menu

multi warning and segmentation fault when compiling opgui 12.0

jmarg38
2022-12-08
2023-02-05
  • jmarg38

    jmarg38 - 2022-12-08

    Hi,
    I'm trying to compile the opgui 12.0 on a Linux xubuntu 22.04. Unfortunately, the build process generates a lot of warning and the final bin opgui falls in segmentation fault when running
    The CLI OP build compiles well on its side

    xubuntu: 22.04
    gcc 11.3.0
    package libgtk-3.0 installed (bin, common, dev, perl)

    sample of the compilation warnings:
    ......
    opgui.c:1598:17: warning: format not a string literal and no format arguments [-Wformat-security]
    1598 | if(saveLog&&logfile) fprintf(logfile,strings[S_comTimeout]);
    | ^~
    opgui.c: In function ‘main’:
    opgui.c:1778:17: warning: format not a string literal and no format arguments [-Wformat-security]
    1778 | printf(strings[I_GUI_CMD_HELP]);
    | ^~~~~~
    opgui.c:1802:17: warning: format not a string literal and no format arguments [-Wformat-security]
    1802 | else printf(strings[S_noprog]);
    | ^~~~
    opgui.c: In function ‘DisplayEE’:
    opgui.c:1272:42: warning: ‘%s’ directive writing up to 255 bytes into a region of size between 246 and 250 [-Wformat-overflow=]
    1272 | sprintf(t,"%04X: %s %s\r\n",i,s,v);
    | ^~ ~
    In file included from /usr/include/stdio.h:894,
    from /usr/include/pango-1.0/pango/pango-utils.h:25,
    from /usr/include/pango-1.0/pango/pango.h:51,
    from /usr/include/gtk-3.0/gdk/gdktypes.h:35,
    from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:30,
    from /usr/include/gtk-3.0/gdk/gdk.h:32,
    from /usr/include/gtk-3.0/gtk/gtk.h:30,
    from common.h:30,
    from opgui.c:24:
    /usr/include/x86_64-linux-gnu/bits/stdio2.h:38:10: note: ‘__builtinsprintfchk’ output between 10 and 524 bytes into a destination of size 256
    38 | return
    builtinsprintfchk (s, __USE_FORTIFY_LEVEL - 1,
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    39 | __glibc_objsize (__s), __fmt,
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    40 | __va_arg_pack ());

     
  • Alberto Maccioni

    Let me try to reproduce the problem

     
  • Alberto Maccioni

    I don't see any problem.
    My system is Mint 19.2 gcc 7.5.0
    Same warnings but the executable runs fine.

     
  • Anonymous

    Anonymous - 2022-12-24

    Ok thanks for your feedback

     
  • Alberto Maccioni

    Does running as super user make any difference?
    (Not that it should be required, just as a trial)

     
  • Anonymous

    Anonymous - 2023-01-10

    Same sentence
    user or sudo
    make clean
    make
    ./opgui
    Segmentation fault (core dumped)

     
  • Anonymous

    Anonymous - 2023-01-10

    It must be noted that it run under ubuntu 18.04 still with warning but without the core dumped.

     
  • Alberto Maccioni

    Can you check the gtk3 version?
    3.12 or later is required

     
  • Anonymous

    Anonymous - 2023-01-11

    yes here it is
    libgtk-3-bin 3.24.33-1ubuntu2 amd64 programs for the GTK graphical user interface library
    ii libgtk-3-common 3.24.33-1ubuntu2 all common files for the GTK graphical user interface library
    ii libgtk-3-dev:amd64 3.24.33-1ubuntu2 amd64 development files for the GTK library

     
  • Anonymous

    Anonymous - 2023-01-20

    hi,
    the problem is in the deviceRW.c
    remove tabulators from beginning of the 345, 386 and 405 rows..
    the 'nameToGroup' function returns with -1 if it found these tabs -> groupNames array does not have -1. member (opgui.c 807.row)
    regards,
    Attila

     
  • Alberto Maccioni

    Nice catch! I'm still not sure why it gives problems only in some environments.
    Anyways, can you try with the original deviceRW.c and the following replacement for line 798 of opgui.c:
    for(tok=strtok(devices,",\t");tok;tok=strtok(NULL,",\t")) {
    It should ignore tab charachters now.

     
  • Anonymous

    Anonymous - 2023-01-21

    hi,
    yes, this is a possible solution (if you will not put any other wild characters into string ;-) ).
    by the way, I think it is not an environment dependent issue, you can reconstruct it: Device -> Filter by type -> * regards,
    Attila

     
  • Anonymous

    Anonymous - 2023-01-21

    but I think it's better way to handle the error
    insert this into opgui.c between 801 and 802 row:
    if (info.group == -1) continue;
    and there is a debug row in deviceRw.c at row 1104, remove the comment and change 'Debug1' to 'PrintMessage1', so it will seen the problem in the canvas if there is any.
    regards,
    Attila

     
  • Anonymous

    Anonymous - 2023-01-21

    ... and put the info.group search and error handling before the info.device memory allocation....

     
  • Alberto Maccioni

    I will add all the above into version 0.12.1

     
  • Anonymous

    Anonymous - 2023-01-26

    I'm glad I could help
    Attila

     
  • jmarg38

    jmarg38 - 2023-02-05

    Thanks a lot, could run now

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.