Bug#888782: fp-compiler-3.0.4: fpselect segfaults on arm64

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug#888782: fp-compiler-3.0.4: fpselect segfaults on arm64

Adam Borowski-3
Package: fp-compiler-3.0.4
Version: 3.0.4+dfsg-14
Severity: normal

Hi!
The following program segfaults on arm64:

.----
uses baseunix;
begin
  fpselect(input, nil)
end.
`----
(Segfault in fpc doesn't give a message, just silently aborts the program
with return code 216.)

On amd64 and armhf, all is ok -- the above program waits for something to be
available on stdin, then completes successfully.


Meow!
-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental')
Architecture: arm64 (aarch64)

Kernel: Linux 4.15.0-00183-ga494935d9d25 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages fp-compiler-3.0.4 depends on:
ii  binutils               2.29.90.20180122-1
ii  debconf [debconf-2.0]  1.5.65
ii  fp-units-rtl-3.0.4     3.0.4+dfsg-14
ii  libc6                  2.26-6

Versions of packages fp-compiler-3.0.4 recommends:
ii  fp-utils-3.0.4  3.0.4+dfsg-14

Versions of packages fp-compiler-3.0.4 suggests:
ii  fp-docs-3.0.4  3.0.4+dfsg-14

-- debconf information:
  fp-compiler/windres:
  fp-compiler/rename_cfg: true
  fp-compiler/windres-select: Select manually

Reply | Threaded
Open this post in threaded view
|

Bug#888782: fp-compiler-3.0.4: fpselect segfaults on arm64

Paul Gevers-4
Hi Adam,

Thanks for reporting this issue. Sorry for not responding earlier, it
must have slipped through the cracks. I'll forward this upstream today.

Paul

On Mon, 29 Jan 2018 21:46:22 +0100 Adam Borowski <[hidden email]>
wrote:

> Package: fp-compiler-3.0.4
> Version: 3.0.4+dfsg-14
> Severity: normal
>
> Hi!
> The following program segfaults on arm64:
>
> .----
> uses baseunix;
> begin
>   fpselect(input, nil)
> end.
> `----
> (Segfault in fpc doesn't give a message, just silently aborts the program
> with return code 216.)
>
> On amd64 and armhf, all is ok -- the above program waits for something to be
> available on stdin, then completes successfully.
>
>
> Meow!
> -- System Information:
> Debian Release: buster/sid
>   APT prefers unstable-debug
>   APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental')
> Architecture: arm64 (aarch64)
>
> Kernel: Linux 4.15.0-00183-ga494935d9d25 (SMP w/4 CPU cores; PREEMPT)
> Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: sysvinit (via /sbin/init)
>
> Versions of packages fp-compiler-3.0.4 depends on:
> ii  binutils               2.29.90.20180122-1
> ii  debconf [debconf-2.0]  1.5.65
> ii  fp-units-rtl-3.0.4     3.0.4+dfsg-14
> ii  libc6                  2.26-6
>
> Versions of packages fp-compiler-3.0.4 recommends:
> ii  fp-utils-3.0.4  3.0.4+dfsg-14
>
> Versions of packages fp-compiler-3.0.4 suggests:
> ii  fp-docs-3.0.4  3.0.4+dfsg-14
>
> -- debconf information:
>   fp-compiler/windres:
>   fp-compiler/rename_cfg: true
>   fp-compiler/windres-select: Select manually
>
>


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Bug#888782: fp-compiler-3.0.4: fpselect segfaults on arm64

Paul Gevers-4
Control: forwarded -1 https://bugs.freepascal.org/view.php?id=34534

On 10-11-18 19:22, Paul Gevers wrote:
>  I'll forward this upstream today.

Done.

Paul


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Bug#888782: fp-compiler-3.0.4: fpselect segfaults on arm64

peter green-2
In reply to this post by Adam Borowski-3
Tags 888782 +patch
Thanks

Freepascal upstream noted that this bug was not present in trunk, but didn't research when/how it was fixed, so I decided to do some digging in the source.

It turns out that the "generic syscalls" implementation of fpSelect (used for aarch64) translates the timeout parameter from a timeval (seconds and microseconds) to a timespec (seconds and nanoseconds) before passing it to the "pselect6" system call.

Unfortunately the version of the code in Debian 3.0.4 fails to check if the timeout is nil, dereferences the nil pointer and segfaults.

Using the "blame" tool on an unofficial github mirror of the freepascal source found the commit fixing the issue.

https://github.com/graemeg/freepascal/commit/e8335a145bfe3af52eed8d0d74ae3a461bbe9d1e

I turned the commit into a quilt patch, added it to the quilt series, built the compiler and was able to confirm it fixed the issue.

Debdiff is attatched, if noone else gets round to it first I'll probably commit and upload within the next week or so.


fpc-select-arm64.debdiff (3K) Download Attachment