I think I found the cause of the problem, hope not to change it’s mind :-).

I had a pchar var used as this:

var pName: pchar;
begin
     <some process>
     getmem( pName, nSizeNeeded );
     <some process>
     freemem( pName );
     <some process>
end;

The exact processing code was:

GetMem( lpLocalBuffer, length( strBuffer ) );
StrPCopy( lpLocalBuffer, strBuffer );
TopicMemoryStream.Clear;
TopicMemoryStream.WriteBuffer( lpLocalBuffer^, length( lpLocalBuffer ) ); 
TopicMemoryStream.Position := 0; FreeMem( lpLocalBuffer );

- lpLocalBuffer is pchar var declared in var section of the function.
- strbuffer is a String.
- TopicMemoryStream is a TMemoryStream.

In simple words, I used pchar var only when needed and freed when done. This 
function is called very often. Noticing that debugger displayed this specific 
unit in most of SIGSEGV cases and this was only the case of memory allocation 
by my self, I decided to declare it as a global var, allocate memory on form 
creation and free it on form destroy. Now it is more stable. There are rare 
ocassions of error messages but I will try to investigate it. Thanks a lot for 
your support.

If my code is OK then Lazarus and FPC gurus may find this interesting for 
investigation.

Panagiotis


-----Original Message-----
From: Alain Michaud [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 29, 2006 2:49 AM
To: [email protected]
Subject: Re: [lazarus] SIGSEGV error


Hi,

  do not be woried, I am just trying to find a solution with you: I saw many 
SIGSEGV messages too. Very often, it was my source that was not right! Make 
sure that your code is perfect!

Alain

On Tue, 2006-03-28 at 20:47 +0000, Panagiotis Sidiropoulos wrote:
> Following backtrace instructions as provided on wiki, I got it running 
> in debug mode. Unfortunately I cannot decode this information. Can you 
> please take a look and guide me about the direction I should 
> investigate my source code?
> 
> (gdb) break fpc_raiseexception
> Breakpoint 1 at 0x8062de6
> (gdb) run
> Starting program: /home/panos/projects/dicrionary.prj/0. Active/mgde 
> [Thread debugging using libthread_db enabled] [New Thread -1217198400 
> (LWP 12502)] TGtk2WSCustomListBox.SetBorder TODO
> 
> (mgde:12502): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion 
> `g_utf8_validate (text, len, NULL)' failed
> 
> Program received signal SIGSEGV, Segmentation fault. [Switching to 
> Thread -1217198400 (LWP 12502)] 0x080680b3 in 
> SYSTEM_TRY_CONCAT_FREE_CHUNK$PMEMCHUNK_VAR
> $$PMEMCHUNK_VAR()
> 
> and battrace report
> 
> (gdb) bt
> #0  0x080680b3 in SYSTEM_TRY_CONCAT_FREE_CHUNK$PMEMCHUNK_VAR
> $$PMEMCHUNK_VAR ()
> #1  0xb6df33a0 in ?? ()
> #2  0x00000100 in ?? ()
> #3  0x08068652 in SYSTEM_SYSFREEMEM_VAR$PMEMCHUNK_VAR$$LONGINT () #4  
> 0xb6df33a0 in ?? () #5  0xbfffe0ac in ?? ()
> #6  0x080686ab in SYSTEM_SYSFREEMEM$POINTER$$LONGINT ()
> #7  0xb73b3e98 in ?? ()
> #8  0xbfffe0ac in ?? ()
> #9  0x08068932 in SYSTEM_SYSREALLOCMEM$POINTER$LONGINT$$POINTER ()
> #10 0x000001c0 in ?? ()
> #11 0x000001aa in ?? ()
> #12 0x000001b7 in ?? ()
> #13 0x0000000d in ?? ()
> #14 0x08067bdd in SYSTEM_REALLOCMEM$POINTER$LONGINT$$POINTER ()
> #15 0x0805de81 in fpc_ansistr_setlength ()
> #16 0xbfffe0ac in ?? ()
> #17 0xbfffe0bc in ?? ()
> #18 0x0000000d in ?? ()
> #19 0x000001aa in ?? ()
> #20 0xb6f0e028 in ?? ()
> #21 0xb710e030 in ?? ()
> #22 0x0805e089 in fpc_ansistr_append_ansistring ()
> #23 0xbfffe0ac in ?? ()
> #24 0xb7013e10 in ?? ()
> #25 0xbfffdfa0 in ?? ()
> #26 0xb6f0e028 in ?? ()
> #27 0x08093c45 in FORMATCURRENTTOPIC (UNFORMATTEDSTRING=
>         {length = 255 '', st = {47 '/', 115 's', 91 '[', 100 'd', 105
> 'i', 100 'd', 122 'z', 104 'h', 69 'E', 115 's', 116 't', 115 's', 104
> 'h', 110 'n', 93 ']', 47 '/', 115 's', 32 ' ', 47 '/', 107 'k', 206 ' ,
> 191 '', 207 ' , 133 '\205', 207
>  ' , 131 '\203', 47 '/', 107 'k', 46 '.', 32 ' ', 47 '/', 99 'c', 207
> ' , 134 '\206', 207 ' , 133 '\205', 207 ' , 131 '\203', 206 ' , 185 '',
> 206 ' , 191 '', 206 ' , 187 '', 47 '/', 99 'c', 46 '.', 32 ' ', 40 '(',
> 207 ' , 137 '\211', 207 ' , 130 '\202', 32 ' ', 206 ' , 187 '', 206 ' ,
> 181 '', 206 ' , 185 '', 207 ' , 132 '\204', 206 ' , 191 '', 207 '
>  , 133 '\205', 207 ' , 129 '\201', 206 ' , 179 '', 206 ' , 175 '', 206
> ' , 177 '', 32 ' ', 206 ' , 186 '', 206 ' , 177 '', 206 ' , 185 '', 32 '
> ', 206 ' , 185 '', 206 ' , 186 '', 206 ' , 177 '', 206 ' , 189 '', 207
> ' , 140 '\214', 207 ' , 132 '\204', 206 ' , 183 '', 207 ' , 132 '\204',
> 206 ' , 177 '', 58 ':', 41 ')', 32 ' ', 47 '/', 120 'x',
>  207 ' , 128 '\200', 206 ' , 173 '', 207 ' , 136 '\210', 206 ' , 183 '',
> 47 '/', 120 'x', 44 ',', 32 ' ', 47 '/', 120 'x', 207 ' , 135 '\207',
> 207 ' , 142 '\216', 206 ' , 189 '', 206 ' , 181 '', 207 ' , 133 '\205',
> 207 ' , 131 '\203', 206 ' , 183 '', 47 '/', 120 'x', 44 ',', 32 ' ', 47
> '/', 120 'x', 206 ' , 177 '', 207 ' , 134 '\206', 206 ' , 191 ''
> , 206 ' , 188 '', 206 ' , 191 '', 206 ' , 175 '', 207 ' , 137 '\211',
> 207 ' , 131 '\203', 206 ' , 183 '', 47 '/', 120 'x', 58 ':', 32 ' ', 47
> '/', 101 'e', 115 's', 117 'u', 98 'b', 115 's', 116 't', 97 'a', 110
> 'n', 99 'c', 101 'e', 32 ' ', 97 'a', 105 'i', 100 'd', 105 'i', 110
> 'n', 103 'g', 32 ' ', 100 'd', 105 'i', 103 'g', 101 'e', 115 's', 116
> 't', 105 '
> i', 111 'o', 110 'n', 47 '/', 101 'e', 32 ' ', 47 '/', 103 'g', 206 ' ,
> 191 '', 207 ' , 133 '\205', 207 ' , 131 '\203'...}}, NCANVASWIDTH=19,
> DICTIONARYDATASET=0xb6f0e028, THEFORM=0xb720e028) at
> dictionariesdrawtopicfunctionsunit.pas:1064
> #28 0x08080211 in TMAINFORM__WORDSFOUNDLISTBOXSELECTIONCHANGE
> (SENDER=0xb7225068, USER=true, this=0xb720e028)
>     at mainunit.pas:1016
> #29 0x0812de8a in TCUSTOMLISTBOX__DOSELECTIONCHANGE (USER=true,
> this=0xb7225068) at customlistbox.inc:399
> #30 0x0812d9e6 in TCUSTOMLISTBOX__LMSELCHANGE (THEMESSAGE={formal}
> 0xbfffe3ec, this=0xb7225068) at customlistbox.inc:239
> #31 0x080623dd in SYSTEM_TOBJECT_$__DISPATCH$formal ()
> #32 0x0812d98c in TCUSTOMLISTBOX__LMMEASUREITEM (THEMESSAGE={MSG = 564,
> IDCTL = 0, MEASUREITEMSTRUCT = 0x0, RESULT = 0},
>     this=0xb7225068) at customlistbox.inc:227
> #33 0x08100bd5 in TWINCONTROL__WNDPROC (MESSAGE=
>       {MSG = 564, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0,
> WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0},
> this=0xb7225068) at wincontrol.inc:3347
> #34 0x081cc34d in DELIVERMESSAGE (TARGET=0xb7225068, AMESSAGE={formal}
> 0xbfffe3ec) at gtkproc.inc:3462
> #35 0x08207a04 in GTK2WS_LISTBOXCHANGE (SELECTION=0x86cc948,
> WIDGETINFO=0xb76dda78) at gtk2wsstdctrls.pp:250
> #36 0xb7b61f0b in g_cclosure_marshal_VOID__VOID ()
> from /usr/lib/libgobject-2.0.so.0
> #37 0xb7b55839 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
> #38 0xb7b650ea in g_signal_stop_emission ()
> from /usr/lib/libgobject-2.0.so.0
> #39 0xb7b66970 in g_signal_emit_valist ()
> from /usr/lib/libgobject-2.0.so.0
> #40 0xb7b66cd9 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
> #41 0xb7d77890 in _gtk_tree_selection_internal_select_node ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #42 0xb7d8acb0 in gtk_tree_view_scroll_to_cell ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #43 0xb7d92dec in gtk_tree_view_set_model ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #44 0xb7cb4b3a in _gtk_marshal_BOOLEAN__ENUM_INT ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #45 0xb7b55179 in g_cclosure_new_swap ()
> from /usr/lib/libgobject-2.0.so.0
> #46 0xb7b55839 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
> #47 0xb7b657f5 in g_signal_stop_emission ()
> from /usr/lib/libgobject-2.0.so.0
> #48 0xb7b660ab in g_signal_emitv () from /usr/lib/libgobject-2.0.so.0
> #49 0xb7be21dd in gtk_bin_get_child () from /usr/lib/libgtk-x11-2.0.so.0
> #50 0xb7be32cc in gtk_binding_set_by_class ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #51 0xb7be3568 in gtk_binding_set_by_class ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #52 0xb7be376d in gtk_bindings_activate_event ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #53 0xb7da5ec8 in gtk_widget_activate ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #54 0xb7d90ba9 in gtk_tree_view_set_search_equal_func ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #55 0xb7cb47f0 in _gtk_marshal_BOOLEAN__BOXED ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #56 0xb7b55179 in g_cclosure_new_swap ()
> from /usr/lib/libgobject-2.0.so.0
> #57 0xb7b55839 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
> #58 0xb7b657f5 in g_signal_stop_emission ()
> from /usr/lib/libgobject-2.0.so.0
> #59 0xb7b666de in g_signal_emit_valist ()
> from /usr/lib/libgobject-2.0.so.0
> #60 0xb7b66cd9 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
> #61 0xb7da60c4 in gtk_widget_activate ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #62 0xb7db6a93 in gtk_window_propagate_key_event ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #63 0xb7dbb23c in gtk_window_activate_key ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #64 0xb7cb47f0 in _gtk_marshal_BOOLEAN__BOXED ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #65 0xb7b55179 in g_cclosure_new_swap ()
> from /usr/lib/libgobject-2.0.so.0
> #66 0xb7b55839 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
> #67 0xb7b657f5 in g_signal_stop_emission ()
> from /usr/lib/libgobject-2.0.so.0
> #68 0xb7b666de in g_signal_emit_valist ()
> from /usr/lib/libgobject-2.0.so.0
> #69 0xb7b66cd9 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
> #70 0xb7da60c4 in gtk_widget_activate ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #71 0xb7cb2d45 in gtk_propagate_event ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #72 0xb7cb3093 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
> #73 0xb7f992da in _gdk_events_queue () from /usr/lib/libgdk-x11-2.0.so.0
> #74 0xb7aebb8c in g_main_context_dispatch ()
> from /usr/lib/libglib-2.0.so.0
> #75 0xb7aeef6b in g_main_context_check () from /usr/lib/libglib-2.0.so.0
> #76 0xb7aef447 in g_main_context_iteration ()
> from /usr/lib/libglib-2.0.so.0
> #77 0xb7cb19c3 in gtk_main_iteration_do ()
> from /usr/lib/libgtk-x11-2.0.so.0
> #78 0x081663b6 in TGTKWIDGETSET__APPWAITMESSAGE (this=0xb7680028) at
> gtkobject.inc:1796
> #79 0x080779d3 in TAPPLICATION__IDLE (WAIT=true, this=0xb76a8028) at
> application.inc:280
> #80 0x08078e01 in TAPPLICATION__HANDLEMESSAGE (this=0xb76a8028) at
> application.inc:900
> #81 0x08079174 in RUNMESSAGE (parentfp=0xbffff9d0) at
> application.inc:1017
> #82 0x080790bf in TAPPLICATION__RUNLOOP (this=0xb76a8028) at
> application.inc:1027
> #83 0x08099fe7 in TWIDGETSET__APPRUN (ALOOP=0x8079080
> <TAPPLICATION__RUNLOOP>, this=0xb7680028) at interfacebase.inc:42
> #84 0x0807906c in TAPPLICATION__RUN (this=0xb76a8028) at
> application.inc:1006
> #85 0x080587c7 in main () at mgde.lpr:26
> 
> Regards, Panagiotis
> 
> Στις 28-03-2006, ημέρα Τρι, και ώρα 19:16 +0200, ο/η Darius Blaszijk
> έγραψε:
> > Panagiotis,
> > 
> > If you want more information on where an error in your app starts, 
> > look at
> > the wiki there's a page on how to make a backtrace. If you still don't see 
> > where the problem is, then post the bt here.
> > 
> > Darius
> > 
> > 
> > ----- Original Message -----
> > From: "Panagiotis Sidiropoulos" <[EMAIL PROTECTED]>
> > To: <[email protected]>
> > Sent: Tuesday, March 28, 2006 5:59 PM
> > Subject: [lazarus] SIGSEGV error
> > 
> > 
> > > While running my application and try several things, I get errors:
> > >
> > > - Project <project title> class 'External: SIGSEGV'
> > > - Access violation
> > >
> > > just the one after the other, if running through IDE. When running 
> > > executable directly I get 'Access violation' only.
> > >
> > > There is not specific point this error is produced so I'm 
> > > completely confused. Maybe it is related to compiler settings, 
> > > maybe this has to do to my limited undestanding of Linux system, I 
> > > don't know. I wish I could provide more information but I do not 
> > > have anything more than above mentioned, at least I don't know 
> > > what information would be useful.
> > >
> > > Searching list archive, Lazarus/FreePascal forums and web, I found 
> > > several related posts, most regarding Windows or prior revisions 
> > > of Lazarus on Linux. I was getting similar error once again and 
> > > was related to sqldb. That problem solved by upgrading fpc and 
> > > lazarus as suggested by list members.
> > >
> > > If anyone is familiar to this, behaviour even not getting 
> > > necessary information, please advise or suggest what to check.
> > >
> > > OS Linux
> > > Lazarus v0.9.13 beta, r9022
> > > FPC r3068
> > >
> > > Regards, Panagiotis
> > >
> > > _________________________________________________________________
> > >     To unsubscribe: mail [EMAIL PROTECTED] with
> > >                "unsubscribe" as the Subject
> > >   archives at http://www.lazarus.freepascal.org/mailarchives
> > 
> > _________________________________________________________________
> >      To unsubscribe: mail [EMAIL PROTECTED] with
> >                 "unsubscribe" as the Subject
> >    archives at http://www.lazarus.freepascal.org/mailarchives
> > 
> 
> _________________________________________________________________
>      To unsubscribe: mail [EMAIL PROTECTED] with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to