OnClick SIGSEVG Exception lazarus / 21-General ---------------------------------------------------------------------- pmesquita · 2021-06-24 13:12 Personal.. I have a problem here that I don't know anymore what it could be... I have a Form (fsMDIForm) where when I click on the TSpeedButton button, all the OnClick event routines are executed (basically it is an SQL that authenticates the user in the database) but when debugging, when executing the entire Begin/End block, an exception SIGSEVG is generated .. Through CallStack I saw that the error is on line 2911 of control.inc Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure TControl.Click;   function OnClickIsActionExecute: boolean;  begin    Result:=false;    if Action=nil then exit;    if not Assigned(Action.OnExecute) then exit;    if not Assigned(FOnClick) then exit;    Result:=CompareMethods(TMethod(FOnClick),TMethod(Action.OnExecute));  end; var  CallAction: Boolean;begin  //DebugLn(['TControl.Click ',DbgSName(Self)]);  CallAction:=(not (csDesigning in ComponentState)) and (ActionLink <> nil);   // first call our own OnClick if it differs from Action.OnExecute  if Assigned(FOnClick)  and ((not CallAction) or (not OnClickIsActionExecute)) then[b]    FOnClick(Self);[/b]  // then trigger the Action  if CallAction then    ActionLink.Execute(Self);end;  Windows 10 x64 Lazarus 2.0.12 FPC 3.2.0 Build Mode: Debug Any idea what it might be or any tips from how can i debug...? ---------------------------------------------------------------------- ADMGNS · 2021-06-26 20:39 hello as my experience, compare with nil have potantial problems.. instead of, kindly you must use 'assigned' always to check.. regs ---------------------------------------------------------------------- Bart · 2021-06-26 21:02 Assigned just checks for nil... ---------------------------------------------------------------------- MarkMLl · 2021-06-26 21:19 Quote from: Bart on June 26, 2021, 11:02:44 pmAssigned just checks for nil... Except where it's checking whether a function returning a pointer (etc.) is assigned, in which case it /specifically/ looks at the function rather than evaluating it and looking at the result. MarkMLl ---------------------------------------------------------------------- jamie · 2021-06-26 23:31 I don't know, I see trouble ahead using Assigned to validate pointers from a function, that is directly wrapping it around a function. ---------------------------------------------------------------------- lucamar · 2021-06-27 05:06 Quote from: jamie on June 27, 2021, 01:31:50 amI don't know, I see trouble ahead using Assigned to validate pointers from a function, that is directly wrapping it around a function. I think what Mark means is validating a var of a procedural type pointing to a function returning a pointer, such as: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  APtrFunction = function: Pointer;  var  TheFunction: APtrFunction;  {...}   if Assigned(TheFunction) then    { ... }; In that specific case Assigned() is guaranteed to check if the var TheFunction is Nil, rather than whether the result of a call to it returns Nil. I don't remember where I read that, though; sorry. ---------------------------------------------------------------------- MarkMLl · 2021-06-27 07:13 Quote from: lucamar on June 27, 2021, 07:06:50 amQuote from: jamie on June 27, 2021, 01:31:50 amI don't know, I see trouble ahead using Assigned to validate pointers from a function, that is directly wrapping it around a function. I think what Mark means is validating a var of a procedural type pointing to a function returning a pointer, such as: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  APtrFunction = function: Pointer;  var  TheFunction: APtrFunction;  {...}   if Assigned(TheFunction) then    { ... }; In that specific case Assigned() is guaranteed to check if the var TheFunction is Nil, rather than whether the result of a call to it returns Nil. I don't remember where I read that, though; sorry. Yes, that's what I mean. It's a consequence of Pascal (unlike Modula-2 and C) not distinguishing between a (pointer to) a function and the result of the function's invocation by whether the function name is followed by parentheses. MarkMLl