Recent

Author Topic: Possible bug on TDBEDIT on Mint - Error, SIGSEGV  (Read 4892 times)

incendio

  • Sr. Member
  • ****
  • Posts: 291
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #30 on: November 21, 2023, 04:09:02 am »
If you have unticked "Generate Debugging Info" in the project options then I am not surprised to see a call to Abort() fail with a segment fault. Suggest you replace with your own exception e.g.

raise Exception.Create("My abort message");

Still got error SIGSEGV
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Dt1BeforeEdit(DataSet: TDataSet);
  2. begin
  3.   if DataIsLock then
  4.   begin
  5.     raise Exception.Create('Can not Edit');
  6.   end;
  7. end;
  8.  

Btw, IBX could not be installed on Lazarus 3, tried it via online Package Manager.

rvk

  • Hero Member
  • *****
  • Posts: 6572
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #31 on: November 21, 2023, 08:46:06 am »
Btw, IBX could not be installed on Lazarus 3, tried it via online Package Manager.
No, even IBX trunk doesn't compile in Lazarus trunk.

You need to add a nil at the place where you get the error.
(Datatype)

BTW. Does the small testproject also crash?
I'll see if I can try it on mint later today.

incendio

  • Sr. Member
  • ****
  • Posts: 291
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #32 on: November 21, 2023, 09:25:46 am »
Btw, IBX could not be installed on Lazarus 3, tried it via online Package Manager.
No, even IBX trunk doesn't compile in Lazarus trunk.

You need to add a nil at the place where you get the error.
(Datatype)

BTW. Does the small testproject also crash?
I'll see if I can try it on mint later today.
Yes, small project gave same error.

rvk

  • Hero Member
  • *****
  • Posts: 6572
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #33 on: November 21, 2023, 09:54:15 am »
..

@tonyw. Besides the missing datatype in trunk the last time I compiled, I now also got an error when downloading the latest IBX via trunk in SVN.
The missing files prevent installation totally.


Edit: Now it seems to be working again... (10:10)

Edit #2: On Linux it still happened. After a svn cleanup ibx and a second try it did work.
(The missing datatype seems to be fixed in the latest trunk)

Command:
Code: Bash  [Select][+][-]
  1. svn co https://svn.mwasoftware.co.uk/public/ibx/trunk ibx

On Windows:
Quote
...
A    ibx\examples\DBAdmin\dlg\DBLoginDlgUnit.lfm
A    ibx\examples\DBAdmin\dlg\NewUserDlgUnit.lfm
A    ibx\examples\DBAdmin\dlg\ShutdownDatabaseDlgUnit.lfm
svn: E175013: Access to '/public/!svn/rvr/380/ibx/trunk/examples/DBAdmin/dlg/BackupDlgUnit.lfm' forbidden

On Linux:
Quote
...
A    ibx/examples/scriptengine/unit2.pas
A    ibx/examples/scriptengine/tests/createproc.sql
A    ibx/examples/scriptengine/unit2.lfm
svn: E175013: Access to '/public/!svn/rvr/421/ibx/trunk/examples/employee/unit1.pas' forbidden
svn: E200042: Additional errors:
svn: E175013: Access to '/public/!svn/rvr/410/ibx/trunk/examples/fbsql/buildAndInstall.sh' forbidden
svn: E175013: Access to '/public/!svn/rvr/380/ibx/trunk/examples/ibstoredproc/Unit1.lfm' forbidden
svn: E175013: Access to '/public/!svn/rvr/158/ibx/trunk/examples/ibstoredproc/fbout-body.sql' forbidden
svn: E175013: Access to '/public/!svn/rvr/380/ibx/trunk/examples/ibstoredproc/ibstoredprocdemo.lpi' forbidden

After that, there are a lot of files missing, not just in example.
« Last Edit: November 21, 2023, 10:31:07 am by rvk »

rvk

  • Hero Member
  • *****
  • Posts: 6572
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #34 on: November 21, 2023, 03:01:12 pm »
The problem is not in IBX or even in TDataset.
The problem is in the Edit components.

I changed the sample project to just do a .Edit and Abort in BeforeEdit and that worked just fine.
When adding a TDBEdit it crashed.
The Abort itself worked fine but when typing text afterwards in the TDBEdit you get the SIGSEGV.

Somehow the TDBEdit keeps hanging in an edit state and creates the SIGSEGV.

The Abort should be the correct way to cancel the operation. SQLdb does this internally itself too.
The Abort will be silent (EAbort) and the operation is cancelled.

But somehow the visual control crashes at that moment (only on Linux).
So it's a bug in SQLdb.

incendio

  • Sr. Member
  • ****
  • Posts: 291
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #35 on: November 21, 2023, 04:53:49 pm »
The problem is not in IBX or even in TDataset.
The problem is in the Edit components.

I changed the sample project to just do a .Edit and Abort in BeforeEdit and that worked just fine.
When adding a TDBEdit it crashed.
The Abort itself worked fine but when typing text afterwards in the TDBEdit you get the SIGSEGV.

Somehow the TDBEdit keeps hanging in an edit state and creates the SIGSEGV.

The Abort should be the correct way to cancel the operation. SQLdb does this internally itself too.
The Abort will be silent (EAbort) and the operation is cancelled.

But somehow the visual control crashes at that moment (only on Linux).
So it's a bug in SQLdb.
I'm confused, where is the bug, TDBEdit or SQLdb?

rvk

  • Hero Member
  • *****
  • Posts: 6572
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #36 on: November 21, 2023, 05:01:36 pm »
I'm confused, where is the bug, TDBEdit or SQLdb?
Sorry, not SQLdb... I think in TDBEdit (but I'm not a core programmer).

I think, somehow, during entering a character in the TDBEdit, the refcount for TDBEdit is decreased to 0 (due to the Abort ??) after which the TDBEdit component is freed (which gives a SIGSEGV exception). But I can't precisely pinpoint how and where.

It's not a bug in FPC or SQLdb because you can freely do a Dataset.Edit and BeforeEdit executes and the dataset stays in dsBrowse because of the Abort. All that doesn't cause the crash. The crash only occurs when you type in a TDBEdit afterwards (when the Dataset is switched to Edit by the DataLink from the TDBEdit).


rvk

  • Hero Member
  • *****
  • Posts: 6572
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #37 on: November 21, 2023, 05:24:42 pm »
I do have a possible solution for you.
In stead of using the BeforeEdit and doing an Abort you can use the AfterEdit and do a Cancel on the Dataset.

This worked for me in my adjusted sample program:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Dt1AfterEdit(DataSet: TDataSet);
  2. begin
  3.   if DataIsLock then
  4.     Datsaet.Cancel;
  5. end;

BTW. It's also really confusing that you switch the dataset of ActDS datasource when switching the Groupbox.
Just add the same eventhandler to Dt1.AfterEdit to Dt2.AfterEdit.
They can point to the same eventhandler and you can use "Dataset" to do your handlings on.

incendio

  • Sr. Member
  • ****
  • Posts: 291
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #38 on: November 22, 2023, 04:38:39 am »
I do have a possible solution for you.
In stead of using the BeforeEdit and doing an Abort you can use the AfterEdit and do a Cancel on the Dataset.

This worked for me in my adjusted sample program:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Dt1AfterEdit(DataSet: TDataSet);
  2. begin
  3.   if DataIsLock then
  4.     Datsaet.Cancel;
  5. end;

BTW. It's also really confusing that you switch the dataset of ActDS datasource when switching the Groupbox.
Just add the same eventhandler to Dt1.AfterEdit to Dt2.AfterEdit.
They can point to the same eventhandler and you can use "Dataset" to do your handlings on.
Thank for your help.

When DataIsLock, I don't wan't users to edit/insert or delete record.

With your method, I pointed All Dataset.AfterEdit & Dataset.AfterInsert to the same event handler, this worked OK, except for delete record.
Although AfterDelete or BeforeDelete pointed to the same handler in AfterEdit event, record still deleted.

So for delete event, I adjusted the code into like these, this is also answering your question about the use of switching ActDs.Dataset (in my app, users must put mouse location in TDBEdit/TDBGrid to choose which record will be deleted)
Code: Pascal  [Select][+][-]
  1. procedure TForm1.btnDelClick(Sender: TObject);
  2. begin
  3.   if (DataIsLock) and (ActDS.DataSet =Dt2) then exit;
  4.   if ActDS.DataSet =Dt1 then Dt1.Delete
  5.   else Dt2.Delete;
  6. end;
  7.  
I think, this is the best solution for now, thanks again.

So, if this a bug in TDBEdit, I will change Thread's Title so others will be aware of this bug in Linux.
« Last Edit: November 22, 2023, 04:41:09 am by incendio »

egsuh

  • Hero Member
  • *****
  • Posts: 1489
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #39 on: November 22, 2023, 08:55:06 am »
If the purpose is to prohibit users to edit a field for records with certain conditions, I would set the DBEdit as readonly in AfterScroll event handler.

   Dt1_Ok2Edit.ReadOnly := DataIsLock or DtTbl1.FieldByName('lck_by').IsNull;

Why Abort causes SEGSIV error? I do not care...  I just use Windows.

incendio

  • Sr. Member
  • ****
  • Posts: 291
Re: IBX, TIBDataset Errror on Mint - Error, SIGSEGV
« Reply #40 on: November 22, 2023, 09:48:34 am »
If the purpose is to prohibit users to edit a field for records with certain conditions, I would set the DBEdit as readonly in AfterScroll event handler.

   Dt1_Ok2Edit.ReadOnly := DataIsLock or DtTbl1.FieldByName('lck_by').IsNull;

Why Abort causes SEGSIV error? I do not care...  I just use Windows.
OK, thanks for your hint, case closed 👍

 

TinyPortal © 2005-2018