Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filehandle read in a thead causes a segfault when the thread ends #4631

Open
p6rt opened this issue Oct 8, 2015 · 6 comments
Open

filehandle read in a thead causes a segfault when the thread ends #4631

p6rt opened this issue Oct 8, 2015 · 6 comments
Labels
SEGV Segmentation fault, bus error, etc. testneeded

Comments

@p6rt
Copy link

p6rt commented Oct 8, 2015

Migrated from rt.perl.org#126297 (status was 'open')

Searchable as RT126297$

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

From @carbin

Doesn't seem to happen if the main program thread is still running when
the thread exits.

  use v6;

  Thread.start({
  my $fh = open('/dev/urandom');
  say $fh.read(16);
  say "alive";
  });

  say "main program ending";

main program ending
Buf[uint8]​:0x<ae c0 d2 b1 fa c9 63 29 1a fb 5c de 56 a2 6a 07>
alive
Segmentation fault (core dumped)

--
Carlin

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

From @lizmat

On 08 Oct 2015, at 14​:43, Carlin Bingham (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Carlin Bingham
# Please include the string​: [perl #​126297]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126297 >

Doesn't seem to happen if the main program thread is still running when
the thread exits.

use v6;

Thread.start({
my $fh = open('/dev/urandom');
say $fh.read(16);
say "alive";
});

say "main program ending";

main program ending
Buf[uint8]​:0x<ae c0 d2 b1 fa c9 63 29 1a fb 5c de 56 a2 6a 07>
alive
Segmentation fault (core dumped)

I wonder if this is another symptom of​:

$ cat /dev/urandom | perl6

===SORRY!===
Malformed UTF-8

Liz

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

From @carbin

On Fri, 9 Oct 2015, at 02​:04 AM, Elizabeth Mattijsen via RT wrote​:

I wonder if this is another symptom of​:

$ cat /dev/urandom | perl6

===SORRY!===
Malformed UTF-8

Liz

It's not specific to /dev/urandom, it happens with a filehandle for a
file with plain ASCII chars​:

  use v6;

  Thread.start({
  my $fh = open('/tmp/blah');
  say $fh.read(16);
  say "alive";
  });

  say "main program ending";

$ cat /tmp/blah
The quick brown fox jumped over the lazy dogs.
$ perl6 bug.pl6
main program ending
Buf[uint8]​:0x<54 68 65 20 71 75 69 63 6b 20 62 72 6f 77 6e 20>
alive
Segmentation fault (core dumped)
$ cat /tmp/blah | perl6

===SORRY!=== Error while compiling <unknown file>
Missing required term after infix
at <unknown file>​:3
------> <BOL>?<EOL>
  expecting any of​:
  dotty method or postfix

--
Carlin

@p6rt
Copy link
Author

p6rt commented Oct 10, 2015

From @nwc10

On Thu, Oct 08, 2015 at 05​:43​:11AM -0700, Carlin Bingham wrote​:

Doesn't seem to happen if the main program thread is still running when
the thread exits.

use v6;

Thread\.start\(\{
    my $fh = open\('/dev/urandom'\);
    say $fh\.read\(16\);
    say "alive";
\}\);

say "main program ending";

ASAN suggests that it's a "regular" SEGV - ie there are no bad memory accesses
leading up to the crash​:

$ ./perl6-m -Ilib 126297
main program ending
Buf[uint8]​:0x<76 35 16 81 97 9f 8c 3f 77 f7 d4 02 00 ff bb 47>
alive
ASAN​:SIGSEGV

==17783==ERROR​: AddressSanitizer​: SEGV on unknown address 0x000000000000 (pc 0x7fc605dfa929 sp 0x7fff1a3952e0 bp 0x7fff1a395310 T0)
  #​0 0x7fc605dfa928 in MVM_gc_root_add_temps_to_worklist src/gc/roots.c​:171
  #​1 0x7fc605dff068 in MVM_gc_collect src/gc/collect.c​:103
  #​2 0x7fc605df36fa in run_gc src/gc/orchestrate.c​:292
  #​3 0x7fc605df404f in MVM_gc_enter_from_allocator src/gc/orchestrate.c​:427
  #​4 0x7fc605da9ab7 in try_join src/core/threads.c​:156
  #​5 0x7fc605daa136 in MVM_thread_join_foreground src/core/threads.c​:243
  #​6 0x7fc605fd01e9 in MVM_vm_exit src/moar.c​:263
  #​7 0x401a82 in main src/main.c​:198
  #​8 0x7fc605563d5c in __libc_start_main (/lib64/libc.so.6+0x1ed5c)
  #​9 0x401058 (/home/nicholas/Sandpit/moar-san/bin/moar+0x401058)

AddressSanitizer can not provide additional info.
SUMMARY​: AddressSanitizer​: SEGV src/gc/roots.c​:171 MVM_gc_root_add_temps_to_worklist
==17783==ABORTING

Nicholas Clark

@p6rt
Copy link
Author

p6rt commented Mar 9, 2018

From @dogbert17

On Sat, 10 Oct 2015 06​:03​:52 -0700, nicholas wrote​:

On Thu, Oct 08, 2015 at 05​:43​:11AM -0700, Carlin Bingham wrote​:

Doesn't seem to happen if the main program thread is still running
when
the thread exits.

use v6;

Thread.start({
my $fh = open('/dev/urandom');
say $fh.read(16);
say "alive";
});

say "main program ending";

ASAN suggests that it's a "regular" SEGV - ie there are no bad memory
accesses
leading up to the crash​:

$ ./perl6-m -Ilib 126297
main program ending
Buf[uint8]​:0x<76 35 16 81 97 9f 8c 3f 77 f7 d4 02 00 ff bb 47>
alive
ASAN​:SIGSEGV

==17783==ERROR​: AddressSanitizer​: SEGV on unknown address
0x000000000000 (pc 0x7fc605dfa929 sp 0x7fff1a3952e0 bp 0x7fff1a395310
T0)
#​0 0x7fc605dfa928 in MVM_gc_root_add_temps_to_worklist
src/gc/roots.c​:171
#​1 0x7fc605dff068 in MVM_gc_collect src/gc/collect.c​:103
#​2 0x7fc605df36fa in run_gc src/gc/orchestrate.c​:292
#​3 0x7fc605df404f in MVM_gc_enter_from_allocator
src/gc/orchestrate.c​:427
#​4 0x7fc605da9ab7 in try_join src/core/threads.c​:156
#​5 0x7fc605daa136 in MVM_thread_join_foreground
src/core/threads.c​:243
#​6 0x7fc605fd01e9 in MVM_vm_exit src/moar.c​:263
#​7 0x401a82 in main src/main.c​:198
#​8 0x7fc605563d5c in __libc_start_main (/lib64/libc.so.6+0x1ed5c)
#​9 0x401058 (/home/nicholas/Sandpit/moar-san/bin/moar+0x401058)

AddressSanitizer can not provide additional info.
SUMMARY​: AddressSanitizer​: SEGV src/gc/roots.c​:171
MVM_gc_root_add_temps_to_worklist
==17783==ABORTING

Nicholas Clark

Fixed as part of jnthn's reframe work in May 2016. Relevant commits are,
AlexDaniel++,
743e7a3dc9a46a2599663e0d448267071831c62c
925336ab25a2e6cd1b6865ce6bbdec97c5be85b8
cebcdd5031c6b6c6e866beee4b52a6a2fd23fcaa
260d5bd2ddd453c31a9e4f2cc9dc0c53bbdd5eea
8b6a4f1fc85846d8d017686a79257b88b165943e
1100877064943356599966c0a241a09b73c99b16

@p6rt p6rt added SEGV Segmentation fault, bus error, etc. testneeded labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SEGV Segmentation fault, bus error, etc. testneeded
Projects
None yet
Development

No branches or pull requests

1 participant