Recent

Author Topic: Weird crashes on Linux  (Read 10813 times)

arximidis

  • New Member
  • *
  • Posts: 25
Weird crashes on Linux
« on: January 30, 2014, 09:28:17 am »
Hello... I am only posting this for the Lazarus team. I have found a solution for the problem and I am ok with that.
Lazarus is becaming a very powerfull RAD tool. So why not make it better?  8)

The following code works perfectly fine on windows
Code: [Select]
var st:TstringList;
begin
  if opendialog.Execute then
    begin
       //ChartArray:=nil;
       st:=TStringList.Create;
       st.LoadFromFile(opendialog.FileName);
       LoadChartData(st);
       st.Clear;
       st.Free;
    end;
end;

but it always crashes on Linux (Linux mint 16). The solution is this

Code: [Select]
var st:TstringList;
begin
try
  if opendialog.Execute then
    begin
       //ChartArray:=nil;
       st:=TStringList.Create;
       st.LoadFromFile(opendialog.FileName);
       LoadChartData(st);
       st.Clear;
       st.Free;
    end;
finally
end;
end;

Thank you

P.S. Sometimes I have issues with copy-paste in the IDE. It doesn't work... It's pasting a previous copied text. I have to close the IDE and reopen to fix the bug

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Weird crashes on Linux
« Reply #1 on: January 30, 2014, 09:37:58 am »
So why not make it better?

Better still would be
Code: [Select]
var st:TstringList;
begin
  if opendialog.Execute then
    begin
      st:=TStringList.Create;
      try
        st.LoadFromFile(opendialog.FileName);
        LoadChartData(st);
      finally
        st.Free;
      end;
    end;
end;

arximidis

  • New Member
  • *
  • Posts: 25
Re: Weird crashes on Linux
« Reply #2 on: January 30, 2014, 11:05:15 am »
No, it crashes before you see the dialog message.
Meaning it crashes on opendialog.execute (and only in Linux. Tested in Linux Mint 16 xfce if I remember correctly)
« Last Edit: January 30, 2014, 11:06:56 am by arximidis »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Weird crashes on Linux
« Reply #3 on: January 30, 2014, 11:38:40 am »
well you solution doesn't make sense any way. an empty try finally block solves your crash? any chance of getting a sample application demonstrating the problem to test?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

arximidis

  • New Member
  • *
  • Posts: 25
Re: Weird crashes on Linux
« Reply #4 on: January 30, 2014, 12:05:39 pm »
I know it doesn't make any sence and that was I call it weird

However I was wrong before
I tested it again.
It doesn't crash when opendialog is trying to open, but while opendialog is open. I get an access violation when I select my home folder
I don't know why, but it does

The only way to correct the error is with the code I posted
Code: [Select]
try
  if opendialog.Execute then
    begin
       //ChartArray:=nil;
       st:=TStringList.Create;
       st.LoadFromFile(opendialog.FileName);
       LoadChartData(st);
       st.Clear;
       st.Free;
    end;
finally
end; 

Now to handle all the cases my fineal code is like this
Code: [Select]
try
  if opendialog.Execute then
    begin
       //ChartArray:=nil;
       st:=TStringList.Create;
       st.LoadFromFile(opendialog.FileName);
       LoadChartData(st);
       st.Clear;
    end;
finally
if assigned(st) then st.free;
end; 

arximidis

  • New Member
  • *
  • Posts: 25
Re: Weird crashes on Linux
« Reply #5 on: January 30, 2014, 12:09:19 pm »
well you solution doesn't make sense any way. an empty try finally block solves your crash? any chance of getting a sample application demonstrating the problem to test?

Yes I will record it and upload it

arximidis

  • New Member
  • *
  • Posts: 25

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9864
  • Debugger - SynEdit - and more
    • wiki
Re: Weird crashes on Linux
« Reply #7 on: January 30, 2014, 01:01:19 pm »
Can you get a stacktrace, when the access violation occurs?

You need to setup/compile for debugging: http://wiki.lazarus.freepascal.org/Debugger_Setup

edvard

  • Full Member
  • ***
  • Posts: 172
Re: Weird crashes on Linux
« Reply #8 on: February 02, 2014, 02:12:42 am »
Just tried your first example on Linux (see my sig) and it works fine.  Other times I have used the "If somedialog.execute..." and it has always worked well.  I suspect something deeper may be wrong.
All children left unattended will be given a mocha and a puppy.

Arch (though I may go back to Debian)| FreePascal 3.2.2 + Lazarus 2.2.4, GTK2+ and Qt.  Mostly Qt...

Rails

  • Guest
Re: Weird crashes on Linux
« Reply #9 on: February 02, 2014, 04:48:23 am »
Just tried your first example on Linux (see my sig) and it works fine.  Other times I have used the "If somedialog.execute..." and it has always worked well.  I suspect something deeper may be wrong.


I have to agree. I have been using openDialog with Debian Linux (xfce4) without any issues at all.

Code: [Select]
fmMain.dialogOpenLFFile.Filter := 'LF|*.' + LFExt;
if fmMain.dialogOpenLFFile.Execute then
  ReadLFFile(fmMain.dialogOpenLFFile.FileName);         

I notice you are running Oracle VirtualBox. I wonder if virtualization is part of  the problem?




benohb

  • Full Member
  • ***
  • Posts: 213
Re: Weird crashes on Linux
« Reply #10 on: February 02, 2014, 09:06:07 am »
Debian Linux + xfce4 + lazarus  svn
No problem ..

arximidis

  • New Member
  • *
  • Posts: 25
Re: Weird crashes on Linux
« Reply #11 on: February 03, 2014, 09:55:16 am »
I have tried it with Linux Mint 14 Cinnamon edition and I have no issues (without even changing the code)!!!

Well, I don't know what is causing the problem...

Yes, In the video I am running Linux Mint 14 xfce inside Virtualbox... and there I always get the error. Maybe it has to do with that fact

For that reason I am using the following code (and I am sure that it will work in all cases)

Code: [Select]
try
  if opendialog.Execute then
    begin
       //ChartArray:=nil;
       st:=TStringList.Create;
       st.LoadFromFile(opendialog.FileName);
       LoadChartData(st);
       st.Clear;
    end;
finally
  if assigned(st) then st.free;
end;   

AndreKappert

  • Newbie
  • Posts: 1
Re: Weird crashes on Linux
« Reply #12 on: October 24, 2014, 12:10:57 pm »
I have had the same problems with opendialog,execute. I tested my program original in Linux Mint Mate 17 64 bits version and Lazarus 1.2.4 with no problems. I tried to make a 32 bits version of my program in a virtualbox with Linux Mate 17 the 32 bits version, Lazarus 1.2.4. There it created a SIGSEGV error. After I had checked I didn't do something wrong in my program, I tried the last Lazarus 1.2.6 version. The problem still exists. I thought maybe the problem is in FPC, which was the same in both lazarus versions. I tried the lazarus and fpc version in the repository of Mate 17, this was 1.0.10 version, vary old. With this Lazarus version opendialog,execute works without any problem but  savedialog,execute suddenly had the same SIGSEGV problem.
   I tried to google this problem and the only thing I could find was a possible problem with the debugger. I have tried to run my program without debugger and the problem still exists, so it's not the debugger.
   When I tried the search function on this website I found this post with the suggestion that the cause is maybe in the use of the virtual box, so I tried to run my program from a Live USB stick with Linux Mate 17 32 bits version. It works without any problem, so the problem only exist in a virtualbox (My version is Oracle VM Virtualbox Version 4.3.16 r95972). I don't think that a virtualbox is appropriate for testing a program made with Lazarus until it is understood why this problem exists and if this problem arises in other functions
   I have tried the try.. finally solution of “arximidis” and it fixes the problem. I don't understand how this could work but it works. 
Here is a stack trace from the problem.
Code: [Select]
#0 ?? at :0
#1 pixman_composite_glyphs_no_mask at :0
#2 ?? at :0
#3 ?? at :0
#4 ?? at :0
#5 ?? at :0
#6 ?? at :0
#7 ?? at :0
#8 ?? at :0
#9 ?? at :0
#10 cairo_show_glyphs at :0
#11 ?? at :0
#12 ?? at :0
#13 pango_renderer_draw_glyphs at :0
#14 pango_renderer_draw_glyph_item at :0
#15 pango_renderer_draw_layout_line at :0
#16 pango_renderer_draw_layout at :0
#17 ?? at :0
#18 ?? at :0
#19 ?? at :0
#20 ?? at :0
#21 ?? at :0
#22 ?? at :0
#23 ?? at :0
#24 ?? at :0
#25 ?? at :0
#26 ?? at :0
#27 ?? at :0
#28 ?? at :0
#29 rsvg_handle_render_cairo_sub at :0
#30 rsvg_handle_get_pixbuf_sub at :0
#31 rsvg_handle_get_pixbuf at :0
#32 ?? at :0
#33 gdk_pixbuf_loader_close at :0
#34 ?? at :0
#35 gdk_pixbuf_new_from_stream_at_scale at :0
#36 ?? at :0
#37 gtk_icon_info_load_icon at :0
#38 ?? at :0
#39 ?? at :0
#40 ?? at :0
#41 ?? at :0
#42 ?? at :0
#43 gtk_tree_model_get_value at :0
#44 gtk_tree_view_column_cell_set_cell_data at :0
#45 ?? at :0
#46 ?? at :0
#47 ?? at :0
#48 ?? at :0
#49 ?? at :0
#50 ?? at :0
#51 g_main_context_dispatch at :0
#52 ?? at :0
#53 g_main_context_iteration at :0
#54 TGTK2WIDGETSET__APPPROCESSMESSAGES(<error reading variable>) at gtk2widgetset.inc:2330
#55 TAPPLICATION__HANDLEMESSAGE(<error reading variable>) at ./include/application.inc:1272
#56 TCOMMONDIALOG__DOEXECUTE(<error reading variable>) at ./include/commondialog.inc:119
#57 TFILEDIALOG__DOEXECUTE(<error reading variable>) at ./include/filedialog.inc:207
#58 TOPENDIALOG__DOEXECUTE(<error reading variable>) at ./include/filedialog.inc:403
#59 TCOMMONDIALOG__EXECUTE(<error reading variable>) at ./include/commondialog.inc:31
#60 TFILEDIALOG__EXECUTE(<error reading variable>) at ./include/filedialog.inc:53
#61 BUTTON2CLICK(0x853c17c, 0x854070c) at hoofdscherm.pas:107
#62 TCONTROL__CLICK(<error reading variable>) at ./include/control.inc:2720
#63 TBUTTONCONTROL__CLICK(<error reading variable>) at ./include/buttoncontrol.inc:54
#64 TCUSTOMBUTTON__CLICK(<error reading variable>) at ./include/buttons.inc:169
#65 TBUTTONCONTROL__WMDEFAULTCLICKED({MSG = 66567, WPARAM = 0, LPARAM = -1215401522, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, LPARAMLO = 29134, LPARAMHI = 46990, RESULTLO = 0, RESULTHI = 0}, <error reading variable>) at ./include/buttoncontrol.inc:20
#66 SYSTEM_TOBJECT_$__DISPATCH$formal at :0
#67 TBUTTONCONTROL__ISCHECKEDSTORED(<error reading variable>) at ./include/buttoncontrol.inc:16
#68 TWINCONTROL__WNDPROC({MSG = 66567, WPARAM = 0, LPARAM = -1215401522, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, LPARAMLO = 29134, LPARAMHI = 46990, RESULTLO = 0, RESULTHI = 0}, <error reading variable>) at ./include/wincontrol.inc:5326
#69 DELIVERMESSAGE(0x854070c, <error reading variable: Attempt to dereference a generic pointer.>) at lclmessageglue.pas:112
#70 GTK2WSBUTTON_CLICKED(0x84eee08, 0x854614c) at gtk2wsstdctrls.pp:2412
#71 g_cclosure_marshal_VOID__VOIDv at :0
#72 ?? at :0
#73 g_signal_emit_valist at :0
#74 g_signal_emit at :0
#75 gtk_button_clicked at :0
#76 ?? at :0
#77 g_cclosure_marshal_VOID__VOIDv at :0
#78 ?? at :0
#79 ?? at :0
#80 g_signal_emit_valist at :0
#81 g_signal_emit at :0
#82 gtk_button_released at :0
#83 ?? at :0
#84 ?? at :0
#85 ?? at :0
#86 g_closure_invoke at :0
#87 ?? at :0
#88 g_signal_emit_valist at :0
#89 g_signal_emit at :0
#90 ?? at :0
#91 gtk_propagate_event at :0
#92 gtk_main_do_event at :0
#93 ?? at :0
#94 g_main_context_dispatch at :0
#95 ?? at :0
#96 g_main_context_iteration at :0
#97 TGTK2WIDGETSET__APPWAITMESSAGE(<error reading variable>) at gtk2widgetset.inc:2408
#98 TAPPLICATION__IDLE(true, <error reading variable>) at ./include/application.inc:405
#99 TAPPLICATION__HANDLEMESSAGE(<error reading variable>) at ./include/application.inc:1273
#100 TAPPLICATION__RUNLOOP(<error reading variable>) at ./include/application.inc:1405
#101 TWIDGETSET__APPRUN(0x8090ad0 <TAPPLICATION__RUNLOOP>, <error reading variable>) at ./include/interfacebase.inc:54
#102 TAPPLICATION__RUN(<error reading variable>) at ./include/application.inc:1393
#103 main at DVDtoHP.lpr:32

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Weird crashes on Linux
« Reply #13 on: October 24, 2014, 12:27:43 pm »
   When I tried the search function on this website I found this post with the suggestion that the cause is maybe in the use of the virtual box, so I tried to run my program from a Live USB stick with Linux Mate 17 32 bits version. It works without any problem, so the problem only exist in a virtualbox (My version is Oracle VM Virtualbox Version 4.3.16 r95972). I don't think that a virtualbox is appropriate for testing a program made with Lazarus until it is understood why this problem exists and if this problem arises in other functions
It is very, very, VERY unlikely there is a problem with virtualbox. The problem is much more likely to be the configuration/software of the virtual machine in question.

If in doubt, export the virtualbox image and run it under e.g. kvm or vmware. If you do not see the same problem, yes it is virtualbox.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018