Recent

Author Topic: fcl-web bug  (Read 4289 times)

vincococka

  • Full Member
  • ***
  • Posts: 101
fcl-web bug
« on: April 28, 2015, 12:25:07 am »
Hi all,

my setup: ArchLinux x64, fpc from trunk (rev 30739).
Running FCGI daemon and calling module method forces application to crash with following backtrace:
Code: [Select]
Program received signal SIGSEGV, Segmentation fault.
MOVE (SOURCE=0, DEST=0, COUNT=7505560) at ../x86_64/x86_64.inc:134
134         mov    (%rcx,%rdx,1),%rax

(gdb) bt
#0  MOVE (SOURCE=0, DEST=0, COUNT=7505560) at ../x86_64/x86_64.inc:134
#1  0x000000000046b8f3 in WRITE (this=0x728658, BUFFER=0, COUNT=16) at ../objpas/classes/streams.inc:760
#2  0x000000000046a0b0 in WRITEBUFFER (this=0x728658, BUFFER=0, COUNT=16)
    at ../objpas/classes/streams.inc:208
#3  0x0000000000499777 in INITPOSTVARS (this=0x727508) at fcl-web/src/base/httpdefs.pp:1770
#4  0x000000000049965f in INITREQUESTVARS (this=0x727508) at fcl-web/src/base/httpdefs.pp:1739
#5  0x0000000000432865 in PROCESSFCGIRECORD (this=0x727508, AFCGIRECORD=0x7282d8)
    at fcl-web/src/base/custfcgi.pp:270
#6  0x0000000000434604 in PROCESSRECORD (this=0x714af8, AFCGI_RECORD=0x7282d8, AREQUEST=0x0,
    ARESPONSE=0x0) at fcl-web/src/base/custfcgi.pp:873
#7  0x0000000000434955 in WAITFORREQUEST (this=0x714af8, AREQUEST=0x0, ARESPONSE=0x0)
    at fcl-web/src/base/custfcgi.pp:964
#8  0x000000000049e2bc in RUN (this=0x714af8) at fcl-web/src/base/custweb.pp:215
#9  0x000000000049feec in DORUN (this=0x714a38) at fcl-web/src/base/custweb.pp:643
#10 0x000000000045eac6 in RUN (this=0x714a38) at fcl-base/src/custapp.pp:286
#11 0x0000000000401d69 in main () at fcgilesnik.lpr:101

FCGI daemon compiled with 2.6.4 and everything works as expected.
Any clues whats going on there?

Greets,
  Vince
« Last Edit: April 28, 2015, 07:18:44 pm by vincococka »
---
  Guide me God and I`ll find you

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fpWeb crash
« Reply #1 on: April 28, 2015, 06:58:02 am »
There seems to be some regressions in fcl-web trunk, I've reported at least three (two fixed), probably more as I find more bugs. Please report as well.

vincococka

  • Full Member
  • ***
  • Posts: 101
fpc/linux64 crash
« Reply #2 on: April 28, 2015, 08:43:06 am »
Hi Lele,

Yeah, on first sight it seems like a fcl-web bug, but if you inspect precisely function parameters (especially Move) you'll see discrepancy between Count parameters (16 vs 7505560).

So there seems to be bug in compiler that will need further investigation.

Greets,
  Vince
---
  Guide me God and I`ll find you

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc bug
« Reply #3 on: April 28, 2015, 01:04:44 pm »
Hi all,

isn`t SizeInt vs LongInt the culprit ?

Take a look inside rtl/x86_64/x86_64.inc and find definition of procedure Move, we will see it`s defined like this:
Code: [Select]
procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];assembler;nostackframe;

Parameter "count" is defined as SizeInt, and "SizeInt" is defined in same file as
Code: [Select]
{$ifdef CPU64}
  SizeInt = Int64; // 8 bytes
{$endif CPU64}

{$ifdef CPU32}
  SizeInt = Longint; // 4 bytes
{$endif CPU32} 

But in streams.inc ---> TMemoryStream.Write function, we will find that parameter Count is defined as LongInt (4 bytes).
I think we have here some sort of discrepancy (if I`m not mistaken), because on x86_64 System.Move expects Int64, not LongInt.

In streams.inc (760): System.Move (Buffer,(FMemory+FPosition)^,Count); // "Count" here is LongInt, but Move expects Int64 on x64_64
---
  Guide me God and I`ll find you

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: fpc bug
« Reply #4 on: April 28, 2015, 03:21:50 pm »
FPC will do automatically type conversion, so I don't see here a problem. Can you attach your project (sources only, no executable or other binaries) here so we can see where is the problem?

EDIT: Ah, saw the backtrace. But SOURCE and DEST are both NIL (0). Stack corruption, maybe?
« Last Edit: April 28, 2015, 03:35:48 pm by Cyrax »

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc bug
« Reply #5 on: April 28, 2015, 06:43:13 pm »
Yeah, my idea around SizeInt and Int64 discrepancy was completely wrong.

After some playing with REST client in Firefox problem seems to lie in parsing HTTP POST parameters (which backtrace prooves with Buffer=0).

But why is it OK with 2.6.4, and fpc/Trunk is crashing?
---
  Guide me God and I`ll find you

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc bug
« Reply #6 on: April 28, 2015, 07:18:28 pm »
I`ve tried svn rev.30549, and it works OK.
Revision 30550 and newer are crashing.

By the way - 30550 received huge fcl-web update by Michael.
Time to investigate where is the culprit :).
---
  Guide me God and I`ll find you

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: fcl-web bug
« Reply #7 on: April 28, 2015, 07:51:35 pm »
Please create a report in to the bugtracker.

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fcl-web bug
« Reply #8 on: April 28, 2015, 10:25:31 pm »
---
  Guide me God and I`ll find you

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fcl-web bug
« Reply #9 on: April 29, 2015, 07:47:04 am »
It may look weird (TMemoryStream -> System.Move), but it's indeed regression. Michael has just fixed another bug I reported in 30744, so if you have less than that, update. I will keep searching for bugs since I use fcl-web extensively.

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fcl-web bug
« Reply #10 on: April 29, 2015, 09:03:38 am »
Hi all,

yeah, I`ve tested svn rev 30745 and now things works as expected.

PS: It`s truly amazing how great community FPC/Lazarus has.

---
  Guide me God and I`ll find you

 

TinyPortal © 2005-2018