libwww-perl / URI

The Perl URI module
https://metacpan.org/pod/URI
Other
41 stars 48 forks source link

Segmentation fault if URI::https is not loaded before `URI->new( 'https://shared.cpanel.projo.net' )` #98

Closed KES777 closed 2 years ago

KES777 commented 2 years ago

Hi, I do not know what is happened on my perl 5.34.1, but when I try to: URI->new( 'http://shared.cpanel.projo.net' )

I get segmentation fault:

HERE URI
HERE URI2
HERE URI3
HERE URI5 
XX at /opt/c/local/lib/perl5/URI.pm line 110, <STDIN> line 28.
X2 at /opt/c/local/lib/perl5/URI.pm line 117, <STDIN> line 28.
Z3 at /opt/c/local/lib/perl5/URI.pm line 128, <STDIN> line 28.
Z4 at /opt/c/local/lib/perl5/URI.pm line 136, <STDIN> line 28.
DFG at /opt/c/local/lib/perl5/URI.pm line 145, <STDIN> line 28.
LOAD URI::https at /opt/c/local/lib/perl5/URI.pm line 148, <STDIN> line 28.
Segmentation fault (core dumped)

image

image

But if I use URI::https before URI->new then everything is working (this is not minimal example). Though it is always reproducible in my environment.

use URI::https;
URI->new( 'http://shared.cpanel.projo.net' );

I understand that this is strange, but it is that I have. Do you have any suggestions or proposition how to fix/debug that?

karenetheridge commented 2 years ago

Can you reproduce this as a oneliner? e.g. perl -MURI -wle'print URI->new( "http://shared.cpanel.projo.net" )' works fine for me. If so, try adding -d:Confess to the options to get a stack trace.

KES777 commented 2 years ago

Sorry. URL is https.

perl -MURI -wle'print URI->new( "https://shared.cpanel.projo.net" )' - works fine

When I run application with -d:Confess - there is no segfault.

Implementor called at /opt/chimera/local/lib/perl5/URI.pm line 66.

Eval::Closure::Sandbox_1824 - accessor Cpanel::base_uapi_url (defined at /opt/chimera/dancer/../lib/Cpanel.pm line 531) - 11 - Cpanel::_build_base_uapi_url - 

Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 573 - __ANON__[accessor Cpanel::base_uapi_url (defined at /opt/chimera/dancer/../lib/Cpanel.pm line 531):23] - 

Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 374 - Cpanel::_uapi_url - 

Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 2979 - Cpanel::call_uapi - 

Email::Cpanel - /opt/chimera/dancer/../lib/Email/Cpanel.pm - 201 - Cpanel::get_mailbox_details - 

Email::Cpanel - /opt/chimera/dancer/../lib/Email/Cpanel.pm - 245 - Email::Cpanel::mailbox_details - 

Action::Test::Email::Premium::Base - /opt/chimera/dancer/ordersystem/t/lib/Action/Test/Email/Premium/Base.pm - 165 - Email::Cpanel::get_mailbox_quota - 

Action::Test::Email::Premium::UpgradeOption::Suspension - dancer/ordersystem/t/lib/Action/Test/Email/Premium/UpgradeOption/Suspension.pm - 87 - Action::Test::Email::Premium::Base::_get_mailbox_quota - 

Action::Test::Email::Premium::UpgradeOption::Suspension - dancer/ordersystem/t/lib/Action/Test/Email/Premium/UpgradeOption/Suspension.pm - 38 - Action::Test::Email::Premium::UpgradeOption::Suspension::_test_suspension - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 469 - Action::Test::Email::Premium::UpgradeOption::Suspension::test_suspension - 

Test2::AsyncSubtest - /opt/chimera/local/lib/perl5/Test2/AsyncSubtest.pm - 215 - Test::Class::Moose::Role::Executor::__ANON__[/opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm:471] - 

Test2::AsyncSubtest - /opt/chimera/local/lib/perl5/Test2/AsyncSubtest.pm - 215 - (eval) - 

Test2::Tools::AsyncSubtest - /opt/chimera/local/lib/perl5/Test2/Tools/AsyncSubtest.pm - 25 - Test2::AsyncSubtest::run - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 472 - Test2::Tools::AsyncSubtest::async_subtest - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 26 - Test::Class::Moose::Role::Executor::__ANON__[/opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm:493] - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 25 - (eval) - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 493 - Test::Class::Moose::Util::context_do - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 262 - Test::Class::Moose::Role::Executor::run_test_method - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 26 - Test::Class::Moose::Role::Executor::__ANON__[/opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm:279] - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 25 - (eval) - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 279 - Test::Class::Moose::Util::context_do - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 180 - Test::Class::Moose::Role::Executor::run_test_instance - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 162 - Test::Class::Moose::Role::Executor::_maybe_wrap_test_instance - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 26 - Test::Class::Moose::Role::Executor::__ANON__[/opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm:171] - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 25 - (eval) - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 171 - Test::Class::Moose::Util::context_do - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 121 - Test::Class::Moose::Role::Executor::_run_test_instances - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 103 - Test::Class::Moose::Role::Executor::run_test_class - 

Test2::AsyncSubtest - /opt/chimera/local/lib/perl5/Test2/AsyncSubtest.pm - 215 - Test::Class::Moose::Role::Executor::__ANON__[/opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm:103] - 

Test2::AsyncSubtest - /opt/chimera/local/lib/perl5/Test2/AsyncSubtest.pm - 215 - (eval) - 

Test2::Tools::AsyncSubtest - /opt/chimera/local/lib/perl5/Test2/Tools/AsyncSubtest.pm - 25 - Test2::AsyncSubtest::run - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 104 - Test2::Tools::AsyncSubtest::async_subtest - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 61 - Test::Class::Moose::Role::Executor::_run_test_classes - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 26 - Test::Class::Moose::Role::Executor::__ANON__[/opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm:71] - 

Test::Class::Moose::Util - /opt/chimera/local/lib/perl5/Test/Class/Moose/Util.pm - 25 - (eval) - 

Test::Class::Moose::Role::Executor - /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm - 71 - Test::Class::Moose::Util::context_do - 

Eval::Closure::Sandbox_275 - inline delegation in Test::Class::Moose::Runner for _executor->runtests (attribute declared in /opt/chimera/local/lib/perl5/Test/Class/Moose/Runner.pm at line 51) - 18 - Test::Class::Moose::Role::Executor::runtests - 

Test::Chimera - /opt/chimera/dancer/../lib/Test/Chimera.pm - 154 - __ANON__[inline delegation in Test::Class::Moose::Runner for _executor->runtests (attribute declared in /opt/chimera/local/lib/perl5/Test/Class/Moose/Runner.pm at line 51):19] - 

main - dancer/ordersystem/t/lib/Action/Test/Email/Premium/UpgradeOption/Suspension.pm - 0 - Test::Chimera::INIT - 

main - dancer/ordersystem/t/lib/Action/Test/Email/Premium/UpgradeOption/Suspension.pm - 0 - (eval) - 

Implementor called at /opt/chimera/local/lib/perl5/URI.pm line 66.

Try to connect: 1 1

connect to rabbitmq.local:5672...

[C] --> [S] AnyEvent::RabbitMQ=HASH(0x55c2cc81ada0) Net::AMQP::Frame::Heartbeat=HASH(0x55c2d5ae4740) ch:bless( {
  channel => 0
}, 'Net::AMQP::Frame::Heartbeat' )
Channel closed: Net::AMQP::Frame::Method=HASH(0x55c2d605e438) at /opt/chimera/dancer/../lib/Queue/RabbitMQ.pm line 180.
HERE: on close
Connection reset by peer at /opt/chimera/dancer/../lib/Queue/RabbitMQ.pm line 101.
    Queue::RabbitMQ::__ANON__[/opt/chimera/dancer/../lib/Queue/RabbitMQ.pm:103]("Connection reset by peer") called at /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm line 289
    AnyEvent::RabbitMQ::_server_closed(AnyEvent::RabbitMQ=HASH(0x55c2cc81ada0), CODE(0x55c2d301bad0), "Connection reset by peer") called at /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm line 160
    AnyEvent::RabbitMQ::__ANON__[/opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm:166](AnyEvent::Handle=HASH(0x55c2d3a37488), 1, "Connection reset by peer") called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm line 655
    AnyEvent::Handle::_error(AnyEvent::Handle=HASH(0x55c2d3a37488), "", 1) called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm line 962
    AnyEvent::Handle::__ANON__[/opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm:964]() called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm line 967
    AnyEvent::Handle::_drain_wbuf(AnyEvent::Handle=HASH(0x55c2d3a37488)) called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm line 1008
    AnyEvent::Handle::push_write(AnyEvent::Handle=HASH(0x55c2d3a37488), "\x{8}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{ce}") called at /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm line 632
    AnyEvent::RabbitMQ::_push_write(AnyEvent::RabbitMQ=HASH(0x55c2cc81ada0), Net::AMQP::Frame::Heartbeat=HASH(0x55c2d5ae4740)) called at /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm line 415
    AnyEvent::RabbitMQ::__ANON__[/opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm:416] called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Loop.pm line 325
    AnyEvent::Loop::__ANON__[/opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Loop.pm:326](ARRAY(0x55c2d30069e8)) called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Loop.pm line 212
    AnyEvent::Loop::one_event() called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/Coro/AnyEvent.pm line 225
    Coro::AnyEvent::__ANON__[/opt/chimera/local/lib/perl5/x86_64-linux-gnu/Coro/AnyEvent.pm:228] called at /opt/chimera/local/lib/perl5/x86_64-linux-gnu/Coro.pm line 716
    Coro::_coro_run called at dancer/ordersystem/t/lib/Action/Test/Email/Premium/UpgradeOption/Suspension.pm line 0
context object was never released! This means a testing tool is behaving very badly at /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm line 71.
context object was never released! This means a testing tool is behaving very badly at /opt/chimera/local/lib/perl5/Test/Class/Moose/Role/Executor.pm line 171.
# Test ended with extra hubs on the stack!
# IPC is waiting for children to finish...
Subtest test_suspension did not finish! at /opt/chimera/local/lib/perl5/Test2/AsyncSubtest.pm line 520 during global destruction.

In my case recent calls before segfault:

URI::new > /opt/chimera/dancer/../lib/Cpanel.pm:1595
URI::implementor > /opt/chimera/local/lib/perl5/URI.pm:62
URI::https::BEGIN > /opt/chimera/local/lib/perl5/URI/https.pm:3
strict::import > /opt/chimera/local/lib/perl5/URI/https.pm:3
strict::import <
URI::https::BEGIN <
URI::https::BEGIN > /opt/chimera/local/lib/perl5/URI/https.pm:4
warnings::import > /opt/chimera/local/lib/perl5/URI/https.pm:4
warnings::_bits > /usr/local/lib/perl5/5.34.1/warnings.pm:356
warnings::_expand_bits > /usr/local/lib/perl5/5.34.1/warnings.pm:312
warnings::_expand_bits <
warnings::_bits <
warnings::import <
URI::https::BEGIN <
URI::https::BEGIN > /opt/chimera/local/lib/perl5/URI/https.pm:9
parent::import > /opt/chimera/local/lib/perl5/URI/https.pm:9
parent::import <
URI::https::BEGIN <

$ cat lib/Cpanel.pm:1595

...
    my $canonical_login_url = URI->new($cpanel_login_url);
    return $canonical_login_url->canonical->as_string;

Stack trace:

Implementor called at /opt/chimera/local/lib/perl5/URI.pm line 66.

Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 1595 - URI::new -
Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 543 - Cpanel::get_login_url -
Eval::Closure::Sandbox_1824 - (eval 2618)[/opt/chimera/local/lib/perl5/Eval/Closure.pm:149] - 16 - Cpanel::_build_base_uapi_url -
Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 573 - Cpanel::base_uapi_url -
Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 374 - Cpanel::_uapi_url -
Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 414 - Cpanel::call_uapi -
Cpanel - /opt/chimera/dancer/../lib/Cpanel.pm - 2956 - Cpanel::call_uapi_or_die -
Email::Cpanel - /opt/chimera/dancer/../lib/Email/Cpanel.pm - 147 - Cpanel::list_mailboxes -
App::MailboxProcessor - /opt/chimera/dancer/../lib/App/MailboxProcessor.pm - 134 - Email::Cpanel::get_domain_mailboxes -
App::MailboxProcessor - /opt/chimera/dancer/../lib/App/MailboxProcessor.pm - 97 - App::MailboxProcessor::_sync_mailbox_spec -
App::MailboxProcessor - /opt/chimera/dancer/../lib/App/MailboxProcessor.pm - 73 - App::MailboxProcessor::_really_process_item -
App::MailboxProcessor - /opt/chimera/dancer/../lib/App/MailboxProcessor.pm - 75 - (eval) -
Role::Queue::Worker - /opt/chimera/dancer/../lib/Role/Queue/Worker.pm - 84 - App::MailboxProcessor::process_item -
Try::Tiny - /opt/chimera/local/lib/perl5/Try/Tiny.pm - 102 - Role::Queue::Worker::try {...}  -
Try::Tiny - /opt/chimera/local/lib/perl5/Try/Tiny.pm - 93 - (eval) -
Role::Queue::Worker - /opt/chimera/dancer/../lib/Role/Queue/Worker.pm - 93 - Try::Tiny::try -
Queue::RabbitMQ - /opt/chimera/dancer/../lib/Queue/RabbitMQ.pm - 529 - Role::Queue::Worker::__ANON__[/opt/chimera/dancer/../lib/Role/Queue/Worker.pm:94] -
AnyEvent::RabbitMQ::Channel - /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ/Channel.pm - 941 - Queue::RabbitMQ::__ANON__[/opt/chimera/dancer/../lib/Queue/RabbitMQ.pm:533] -
AnyEvent::RabbitMQ::LocalQueue - /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ/LocalQueue.pm - 41 - AnyEvent::RabbitMQ::Channel::__ANON__[/opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ/Channel.pm:943] -
AnyEvent::RabbitMQ::LocalQueue - /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ/LocalQueue.pm - 20 - AnyEvent::RabbitMQ::LocalQueue::_drain_queue -
AnyEvent::RabbitMQ::Channel - /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ/Channel.pm - 910 - AnyEvent::RabbitMQ::LocalQueue::push -
AnyEvent::RabbitMQ - /opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm - 243 - AnyEvent::RabbitMQ::Channel::push_queue_or_consume -
AnyEvent::Handle - /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm - 1505 - AnyEvent::RabbitMQ::__ANON__[/opt/chimera/local/lib/perl5/AnyEvent/RabbitMQ.pm:251] -
AnyEvent::Handle - /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm - 1315 - AnyEvent::Handle::__ANON__[/opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm:1507] -
AnyEvent::Handle - /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm - 2015 - AnyEvent::Handle::_drain_rbuf -
AnyEvent::Loop - /opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Loop.pm - 248 - AnyEvent::Handle::__ANON__[/opt/chimera/local/lib/perl5/x86_64-linux-gnu/AnyEvent/Handle.pm:2035] -
Coro::AnyEvent - /opt/chimera/local/lib/perl5/x86_64-linux-gnu/Coro/AnyEvent.pm - 225 - AnyEvent::Loop::one_event -
Coro - /opt/chimera/local/lib/perl5/x86_64-linux-gnu/Coro.pm - 716 - Coro::AnyEvent::__ANON__[/opt/chimera/local/lib/perl5/x86_64-linux-gnu/Coro/AnyEvent.pm:228] -
main - dancer/ordersystem/t/lib/Action/Test/Email/Premium/UpgradeOption/Suspension.pm - 0 - Coro::_coro_run -
Segmentation fault (core dumped)

image

image

Strange thing here is that URI::implementor call is not visible as stack frame.

oalders commented 2 years ago

Pinging @FGasper since I see Cpanel in the stack.

FGasper commented 2 years ago

Coro and RabbitMQ are decidedly un-cPanel-ish (i.e., I’ve not seen them in cP’s code, and I know of no initiative to introduce either) … I’m not sure what’s going on there. I would guess that’s someone’s external code written to interface w/ cPanel.

KES777 commented 2 years ago

Yes, lib/Cpanel is our internal library.

oalders commented 2 years ago

@KES777 this could be a good question for StackOverflow, where you might get more eyeballs on the problem to establish if there's an actual bug in URI.

karenetheridge commented 2 years ago

I'm not sure how we can provide direct help without some sort of reproduction case, preferrably a small one.

KES777 commented 2 years ago

Found another couple of modules with similar issues. What is similar to URI::https they are very simple and use parent:

package Registrar::Nominet::couk;

use our::way;
use parent qw( Registrar::Nominet::EPP );  <<< segfault on this line

1;

So this is not related to URI::implementor. Closing this. Thank you.

oalders commented 2 years ago

Thanks for the follow-up @KES777. We really appreciate the closed ticket. 😄