Menu

#111 Segmentation fault with @ x,y bitmap

v1.0_(example)
closed
nobody
1
2022-09-14
2022-08-09
No

Hi, I have a function which crashes when I call it a second time.

The function in execute.prg is named Afaire() uses hcedit and the functions isLock(), idOver() in keyboard.prg
If I comment all the @x,y bitmap, it doesn't crash anymore because a Segmentation fault, just an error (normal). If I add a comment before ON ACTIVATE, no more error.

Where do I fail ?

A+

2 Attachments

Discussion

  • Aupeix Alain

    Aupeix Alain - 2022-08-09

    Hi, this function is present in all my programs, ans it doesn't crash when I dont use embedded images

       @  20, 570 BITMAP oocaps_afaire SHOW cimagedir+"/capson.png" TOOLTIP "Verrouillage majuscule actif"
       @  20, 570 BITMAP ofcaps_afaire SHOW cimagedir+"/capsoff.png" TOOLTIP "Verrouillage majuscule actif"
       @  65, 570 BITMAP oonum_afaire  SHOW cimagedir+"/numon.png" TOOLTIP "Verrouillage numérique actif"
       @  65, 570 BITMAP ofnum_afaire  SHOW cimagedir+"/numoff.png" TOOLTIP "Verrouillage numérique actif"
       @ 110, 570 BITMAP oover_afaire SHOW cimagedir+"/over.png" TOOLTIP "Mode ECR/INS"
       @ 110, 570 BITMAP oins_afaire  SHOW cimagedir+"/ins.png" TOOLTIP "Mode ECR/INS"
    

    It seems to be the reason.
    Is-it a bug or is-it normal ?

    Thanks
    A+

     

    Last edit: Aupeix Alain 2022-08-09
  • Wilfried Brunken

    Hello Alain,
    to reproduce the bug i tried to compile the HWMAKE utility with some modifications,
    please check commit of r15.

    The build of hwmake was successful,
    but i got some error messages
    listed in the appenden text file.

    I am very busy, can you look for ?
    But another way is to post a sample program with hbp file only demonstrating the bug.

    A long time ago, i checked the usage of bitmaps and i added the following
    information:
    4.3.28. @ <x>,<y> BITMAP
    ...
    Supported image formats see documentation for CLASS HBITMAP.</y></x>

    The parameters <obmp> SHOW , SIZE and "OF" are on GTK mandatory,
    otherwise the image does not appear !
    For details see sample program "bincnts.prg".
    For the SIZE parameter pass the real size of the image to display.</obmp>

    Best regards,
    TNX, MNI 73 es 55 de
    DF/BE, Wilfried
    
     
  • Wilfried Brunken

    Hello Alain,
    I created ticket #1 on project HWLABEL with title:
    Open discussion for developpers
    to continue our discussion on Tickets #109 and #111.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-08-12

    HWLABEL ?

    Are you sure ?

     
  • Wilfried Brunken

    Hello Alain,
    sorry, very hot here,
    of course HWMAKE !

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-08-17

    Hi, here is the test for the bug with hex BITMAP.

    Thanks
    A+

     
  • Wilfried Brunken

    Hello Alain,
    i attached the used hbp file.

    I got a compile message:
    Test_image.prg(250) Warning W0001 Ambiguous reference 'CBUTTON'

    So i detected, that the variable "cButton" is not declared and filled with a value in
    function IsOver()

    Please send me the modification.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Wilfried Brunken

    Hello Alain,
    to continue my work, i commented out the -w option.
    I started the program and it crashes at pressing the cross button:
    Error BASE/1003 Variable does not exist: ONCAPS_AFAIRE.
    In background the dialog window is visible

    The run command works OK:
    sh -c 'xset -q | grep Caps'
    00: Caps Lock: off 01: Num Lock: off 02: Scroll Lock: off

    I have an idea:
    For multi platform usage, it is at it best, to use BMP instead of PNG.
    For conversion install the package "imagemagick" on the LINUX system
    and say
    convert xyz.png -depth 8 xyz.bmp
    (-depth 8 = 256 colours)

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-08-19

    Hi,

    For the missing declaration of cButton, it's an error, no need of cButton in isOver():

       ovButton="oOver_"+cfunction
    //  ovButton="o"+cButton+"_"+cfunction
    

    I had already install imagemagick, this nice tool.
    I have replaced num, caps ins and over png by bmp, and regenerated inithex.prg
    I have completed public declaration of o?nm_Afaire, o?caps_Afaire, oins_Afaire and oover_Afaire

    No more warning when building, but it always crash the second time I call RunError()

    Where do I always fail ?
    Have you also this crash ?

    The run command works OK:
    sh -c 'xset -q | grep Caps'
    00: Caps Lock: off 01: Num Lock: off 02: Scroll Lock: off
    

    Yes but 'Scroll Lock' isn't correctly reported (always off)

    Here is a modified version, as said, of Test_image.

    Thanks
    A+

     
  • Wilfried Brunken

    Hello Alain,
    i spent some time to find the reason for
    the crash, the solution is very simple.

    With commit r3109 i added the following information:

    see file utils/bincnt/Readme.txt:

    Attention !
    On GTK a core dump is possible, if the object variables are not defined as LOCAL.
    (Reference Bug Ticket #111).
    
    See Sample "hexbincnt.prg":
    
    In the old version the call of  showbitmap(oBMPExit)
    crashes.
    
    At first, the variable oBMPExit was declared as PUBLIC
    and passed to function showbitmap(): 
    // oBMPExit2 := HBitmap():AddString( "exit2" , cValexit2 )
    
    Now the function is modified and needed the following parameters to pass:
    showbitmap(cValopen,"open")
    - cValopen is the binary value created by hwg_cHex2Bin()
    - "open" is the name of resource.
    
    It seems, that the internal GTK variables are overwritten.
    

    The appended archive contains your test program
    with the fixed error, please check.

    Please give feedback, if this ticket can be closed.

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Aupeix Alain

    Aupeix Alain - 2022-08-27

    Hi Wilfried,

    Yes this solve the crash.

    I just make local.prg like this, to avoid having to insert HBitmap():addstring() lines in the function:

    // Local objects for hex images
    
    local  oObj_capson:=""
    local  oObj_capsoff:=""
    local  oObj_numon:=""
    local  oObj_numoff:=""
    local  oObj_over:=""
    local  oObj_ins:=""
    
    oObj_capson := HBitmap():AddString( "capson" , cVal_capson )
    oObj_capsoff := HBitmap():AddString( "capsoff" , cVal_capsoff )
    oObj_numon := HBitmap():AddString( "numon" , cVal_numon )
    oObj_numoff := HBitmap():AddString( "numoff" , cVal_numoff )
    oObj_over := HBitmap():AddString( "over" , cVal_over )
    oObj_ins := HBitmap():AddString( "ins" , cVal_ins )
    

    Obviously, cVal and cHex variables are declared in public.prg and cVal variables are generated in loadhex.prg ... To avoid warning, when the function which use these features is in another prgfile, cVal variables are declared as memvar in the concerned prg.

    And it works like a charm ...
    I will modify my function inclure() in hwmake to generate local.prg,

    You can close.

    Thanks
    A+

     
  • Wilfried Brunken

    Hello Alexander, Hello Maurizio,
    please close this ticket.
    Or may I become the project admin role so that I can handle tickets ?

    With regards,
    MNI TNX, 73 es 55 de
    DF7BE, Wilfried

     
  • Wilfried Brunken

    • status: open --> closed
     
  • Wilfried Brunken

    Ticket Closed.

     

Log in to post a comment.