gen_server: {bad_return_value, {error, {91, invalid_string}}}

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

gen_server: {bad_return_value, {error, {91, invalid_string}}}

Khitai Pang
Hi list,

On my CentOS7 server with esl-erlang-19.3.6-1.x86_64, a gen_server
process mysteriously crashes.  See the error info below.  I can't figure
out the reason of the error.  Any hint would be appreciated.

{error_report,<0.25443.97>,
     {<0.28918.97>,crash_report,
      [[{initial_call,{xeef_analyzer,init,[Argument__1]}},
        {pid,<0.28918.97>},
        {registered_name,xeef_analyzer_009},
        {error_info,
            {exit,
                {bad_return_value,{error,{91,invalid_string}}},
[{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},
                 {proc_lib,init_p_do_apply,3,
                     [{file,"proc_lib.erl"},{line,247}]}]}},
        {ancestors,[xeef_analyzer_sup,xeef_sup,<0.25310.97>]},
{messages,[{basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>}]},
        {links,
[#Port<0.2317500>,#Port<0.2317503>,<0.29009.97>,#Port<0.2317499>]},
        {dictionary,
            [{rand_seed,
                 {#{max => 18446744073709551615,next =>
#Fun<rand.4.41921595>,
                    type => exs1024,uniform => #Fun<rand.5.41921595>,
                    uniform_n => #Fun<rand.6.41921595>},
                  {[5529181756040335035,6774320120208346895,
                    4985297473998268992,12813505499546735856,
                    3059599059795068553,3134963973831305956,
                    5508046504858988103,3821329447243874404],
                   [6547380368325771448,16036002885223559991,
                    13982350927889545678,14401258729428095242,
                    6347438184782916914,10561027033563628251,
                    10847483533189471003,3486622809589930158]}}}]},
        {trap_exit,true},
        {status,running},
        {heap_size,987},
        {stack_size,27},
        {reductions,139726}],
       []]}}


{error_report,<0.25443.97>,
     {<0.29009.97>,supervisor_report,
      [{supervisor,{local,xeef_analyzer_sup}},
       {errorContext,child_terminated},
       {reason,{bad_return_value,{error,{91,invalid_string}}}},
       {offender,
           [{pid,<0.28918.97>},
            {id,xeef_analyzer},
            {mfargs,
                {xeef_analyzer,start_link,
[{sandbox,{<0.28962.97>,<<"sanbox_queue">>},none,true}]}},
            {restart_type,permanent},
            {shutdown,5000},
            {child_type,worker}]}]}}



Best wishes,
Khitai
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server: {bad_return_value, {error, {91, invalid_string}}}

Raimo Niskanen-2
On Mon, Aug 14, 2017 at 03:17:38AM +0000, Khitai Pang wrote:

> Hi list,
>
> On my CentOS7 server with esl-erlang-19.3.6-1.x86_64, a gen_server
> process mysteriously crashes.  See the error info below.  I can't figure
> out the reason of the error.  Any hint would be appreciated.
>
> {error_report,<0.25443.97>,
>      {<0.28918.97>,crash_report,
>       [[{initial_call,{xeef_analyzer,init,[Argument__1]}},
>         {pid,<0.28918.97>},
>         {registered_name,xeef_analyzer_009},
>         {error_info,
>             {exit,
>                 {bad_return_value,{error,{91,invalid_string}}},

It seems your gen_server with registered name xeef_analyzer_009 started
from xeef_analyzer:init/1 has returned {error,{91,invalid_string}} from
one of its callbacks.


> [{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},
>                  {proc_lib,init_p_do_apply,3,
>                      [{file,"proc_lib.erl"},{line,247}]}]}},
>         {ancestors,[xeef_analyzer_sup,xeef_sup,<0.25310.97>]},
> {messages,[{basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>}]},
>         {links,
> [#Port<0.2317500>,#Port<0.2317503>,<0.29009.97>,#Port<0.2317499>]},
>         {dictionary,
>             [{rand_seed,
>                  {#{max => 18446744073709551615,next =>
> #Fun<rand.4.41921595>,
>                     type => exs1024,uniform => #Fun<rand.5.41921595>,
>                     uniform_n => #Fun<rand.6.41921595>},
>                   {[5529181756040335035,6774320120208346895,
>                     4985297473998268992,12813505499546735856,
>                     3059599059795068553,3134963973831305956,
>                     5508046504858988103,3821329447243874404],
>                    [6547380368325771448,16036002885223559991,
>                     13982350927889545678,14401258729428095242,
>                     6347438184782916914,10561027033563628251,
>                     10847483533189471003,3486622809589930158]}}}]},
>         {trap_exit,true},
>         {status,running},
>         {heap_size,987},
>         {stack_size,27},
>         {reductions,139726}],
>        []]}}
>
>
> {error_report,<0.25443.97>,
>      {<0.29009.97>,supervisor_report,
>       [{supervisor,{local,xeef_analyzer_sup}},
>        {errorContext,child_terminated},
>        {reason,{bad_return_value,{error,{91,invalid_string}}}},
>        {offender,
>            [{pid,<0.28918.97>},
>             {id,xeef_analyzer},
>             {mfargs,
>                 {xeef_analyzer,start_link,
> [{sandbox,{<0.28962.97>,<<"sanbox_queue">>},none,true}]}},
>             {restart_type,permanent},
>             {shutdown,5000},
>             {child_type,worker}]}]}}
>
>
>
> Best wishes,
> Khitai
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server: {bad_return_value, {error, {91, invalid_string}}}

Attila Rajmund Nohl
In reply to this post by Khitai Pang
Hello!

I'd check the code that handles the
{basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>} message,
because this was the last received message. Also my intuition is that
somewhere your code expects a list of strings, but gets a simple
string, and when it checks the first element, it finds 91 (probably
the '[' character) instead of a string.

2017-08-14 5:17 GMT+02:00 Khitai Pang <[hidden email]>:

> Hi list,
>
> On my CentOS7 server with esl-erlang-19.3.6-1.x86_64, a gen_server
> process mysteriously crashes.  See the error info below.  I can't figure
> out the reason of the error.  Any hint would be appreciated.
>
> {error_report,<0.25443.97>,
>      {<0.28918.97>,crash_report,
>       [[{initial_call,{xeef_analyzer,init,[Argument__1]}},
>         {pid,<0.28918.97>},
>         {registered_name,xeef_analyzer_009},
>         {error_info,
>             {exit,
>                 {bad_return_value,{error,{91,invalid_string}}},
> [{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},
>                  {proc_lib,init_p_do_apply,3,
>                      [{file,"proc_lib.erl"},{line,247}]}]}},
>         {ancestors,[xeef_analyzer_sup,xeef_sup,<0.25310.97>]},
> {messages,[{basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>}]},
>         {links,
> [#Port<0.2317500>,#Port<0.2317503>,<0.29009.97>,#Port<0.2317499>]},
>         {dictionary,
>             [{rand_seed,
>                  {#{max => 18446744073709551615,next =>
> #Fun<rand.4.41921595>,
>                     type => exs1024,uniform => #Fun<rand.5.41921595>,
>                     uniform_n => #Fun<rand.6.41921595>},
>                   {[5529181756040335035,6774320120208346895,
>                     4985297473998268992,12813505499546735856,
>                     3059599059795068553,3134963973831305956,
>                     5508046504858988103,3821329447243874404],
>                    [6547380368325771448,16036002885223559991,
>                     13982350927889545678,14401258729428095242,
>                     6347438184782916914,10561027033563628251,
>                     10847483533189471003,3486622809589930158]}}}]},
>         {trap_exit,true},
>         {status,running},
>         {heap_size,987},
>         {stack_size,27},
>         {reductions,139726}],
>        []]}}
>
>
> {error_report,<0.25443.97>,
>      {<0.29009.97>,supervisor_report,
>       [{supervisor,{local,xeef_analyzer_sup}},
>        {errorContext,child_terminated},
>        {reason,{bad_return_value,{error,{91,invalid_string}}}},
>        {offender,
>            [{pid,<0.28918.97>},
>             {id,xeef_analyzer},
>             {mfargs,
>                 {xeef_analyzer,start_link,
> [{sandbox,{<0.28962.97>,<<"sanbox_queue">>},none,true}]}},
>             {restart_type,permanent},
>             {shutdown,5000},
>             {child_type,worker}]}]}}
>
>
>
> Best wishes,
> Khitai
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server: {bad_return_value, {error, {91, invalid_string}}}

Khitai Pang
Hi Raimo, Attila,

I have found out the cause: the handle_info callback of my gen_server
failed to decode a json string:

{Json} = jiffy:decode(Msg),

the above code generates {error, {91, invalid_string}}, and I believe
the error is caught by OTP gen_server code, and somehow the terminate()
function in OTP gen_server code complains about {bad_return_value,
{error, {91, invalid_string}}}.  Now I know the root cause of the
problem but I don't understand why it ends up in an error of
gen_server:terminate().


Best wishes,
Khitai

On 2017/8/14 19:54, Attila Rajmund Nohl wrote:

> Hello!
>
> I'd check the code that handles the
> {basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>} message,
> because this was the last received message. Also my intuition is that
> somewhere your code expects a list of strings, but gets a simple
> string, and when it checks the first element, it finds 91 (probably
> the '[' character) instead of a string.
>
> 2017-08-14 5:17 GMT+02:00 Khitai Pang <[hidden email]>:
>> Hi list,
>>
>> On my CentOS7 server with esl-erlang-19.3.6-1.x86_64, a gen_server
>> process mysteriously crashes.  See the error info below.  I can't figure
>> out the reason of the error.  Any hint would be appreciated.
>>
>> {error_report,<0.25443.97>,
>>       {<0.28918.97>,crash_report,
>>        [[{initial_call,{xeef_analyzer,init,[Argument__1]}},
>>          {pid,<0.28918.97>},
>>          {registered_name,xeef_analyzer_009},
>>          {error_info,
>>              {exit,
>>                  {bad_return_value,{error,{91,invalid_string}}},
>> [{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},
>>                   {proc_lib,init_p_do_apply,3,
>>                       [{file,"proc_lib.erl"},{line,247}]}]}},
>>          {ancestors,[xeef_analyzer_sup,xeef_sup,<0.25310.97>]},
>> {messages,[{basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>}]},
>>          {links,
>> [#Port<0.2317500>,#Port<0.2317503>,<0.29009.97>,#Port<0.2317499>]},
>>          {dictionary,
>>              [{rand_seed,
>>                   {#{max => 18446744073709551615,next =>
>> #Fun<rand.4.41921595>,
>>                      type => exs1024,uniform => #Fun<rand.5.41921595>,
>>                      uniform_n => #Fun<rand.6.41921595>},
>>                    {[5529181756040335035,6774320120208346895,
>>                      4985297473998268992,12813505499546735856,
>>                      3059599059795068553,3134963973831305956,
>>                      5508046504858988103,3821329447243874404],
>>                     [6547380368325771448,16036002885223559991,
>>                      13982350927889545678,14401258729428095242,
>>                      6347438184782916914,10561027033563628251,
>>                      10847483533189471003,3486622809589930158]}}}]},
>>          {trap_exit,true},
>>          {status,running},
>>          {heap_size,987},
>>          {stack_size,27},
>>          {reductions,139726}],
>>         []]}}
>>
>>
>> {error_report,<0.25443.97>,
>>       {<0.29009.97>,supervisor_report,
>>        [{supervisor,{local,xeef_analyzer_sup}},
>>         {errorContext,child_terminated},
>>         {reason,{bad_return_value,{error,{91,invalid_string}}}},
>>         {offender,
>>             [{pid,<0.28918.97>},
>>              {id,xeef_analyzer},
>>              {mfargs,
>>                  {xeef_analyzer,start_link,
>> [{sandbox,{<0.28962.97>,<<"sanbox_queue">>},none,true}]}},
>>              {restart_type,permanent},
>>              {shutdown,5000},
>>              {child_type,worker}]}]}}
>>
>>
>>
>> Best wishes,
>> Khitai
>> _______________________________________________
>> erlang-questions mailing list
>> [hidden email]
>> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server: {bad_return_value, {error, {91, invalid_string}}}

Ali Sabil
Hi Khitai,

That's because jiffy (mis)uses erlang:throw.

Best,
Ali

On Tue, Aug 15, 2017 at 5:13 AM, Khitai Pang <[hidden email]> wrote:
Hi Raimo, Attila,

I have found out the cause: the handle_info callback of my gen_server
failed to decode a json string:

{Json} = jiffy:decode(Msg),

the above code generates {error, {91, invalid_string}}, and I believe
the error is caught by OTP gen_server code, and somehow the terminate()
function in OTP gen_server code complains about {bad_return_value,
{error, {91, invalid_string}}}.  Now I know the root cause of the
problem but I don't understand why it ends up in an error of
gen_server:terminate().


Best wishes,
Khitai

On 2017/8/14 19:54, Attila Rajmund Nohl wrote:
> Hello!
>
> I'd check the code that handles the
> {basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>} message,
> because this was the last received message. Also my intuition is that
> somewhere your code expects a list of strings, but gets a simple
> string, and when it checks the first element, it finds 91 (probably
> the '[' character) instead of a string.
>
> 2017-08-14 5:17 GMT+02:00 Khitai Pang <[hidden email]>:
>> Hi list,
>>
>> On my CentOS7 server with esl-erlang-19.3.6-1.x86_64, a gen_server
>> process mysteriously crashes.  See the error info below.  I can't figure
>> out the reason of the error.  Any hint would be appreciated.
>>
>> {error_report,<0.25443.97>,
>>       {<0.28918.97>,crash_report,
>>        [[{initial_call,{xeef_analyzer,init,[Argument__1]}},
>>          {pid,<0.28918.97>},
>>          {registered_name,xeef_analyzer_009},
>>          {error_info,
>>              {exit,
>>                  {bad_return_value,{error,{91,invalid_string}}},
>> [{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},
>>                   {proc_lib,init_p_do_apply,3,
>>                       [{file,"proc_lib.erl"},{line,247}]}]}},
>>          {ancestors,[xeef_analyzer_sup,xeef_sup,<0.25310.97>]},
>> {messages,[{basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>}]},
>>          {links,
>> [#Port<0.2317500>,#Port<0.2317503>,<0.29009.97>,#Port<0.2317499>]},
>>          {dictionary,
>>              [{rand_seed,
>>                   {#{max => 18446744073709551615,next =>
>> #Fun<rand.4.41921595>,
>>                      type => exs1024,uniform => #Fun<rand.5.41921595>,
>>                      uniform_n => #Fun<rand.6.41921595>},
>>                    {[5529181756040335035,6774320120208346895,
>>                      4985297473998268992,12813505499546735856,
>>                      3059599059795068553,3134963973831305956,
>>                      5508046504858988103,3821329447243874404],
>>                     [6547380368325771448,16036002885223559991,
>>                      13982350927889545678,14401258729428095242,
>>                      6347438184782916914,10561027033563628251,
>>                      10847483533189471003,3486622809589930158]}}}]},
>>          {trap_exit,true},
>>          {status,running},
>>          {heap_size,987},
>>          {stack_size,27},
>>          {reductions,139726}],
>>         []]}}
>>
>>
>> {error_report,<0.25443.97>,
>>       {<0.29009.97>,supervisor_report,
>>        [{supervisor,{local,xeef_analyzer_sup}},
>>         {errorContext,child_terminated},
>>         {reason,{bad_return_value,{error,{91,invalid_string}}}},
>>         {offender,
>>             [{pid,<0.28918.97>},
>>              {id,xeef_analyzer},
>>              {mfargs,
>>                  {xeef_analyzer,start_link,
>> [{sandbox,{<0.28962.97>,<<"sanbox_queue">>},none,true}]}},
>>              {restart_type,permanent},
>>              {shutdown,5000},
>>              {child_type,worker}]}]}}
>>
>>
>>
>> Best wishes,
>> Khitai
>> _______________________________________________
>> erlang-questions mailing list
>> [hidden email]
>> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: gen_server: {bad_return_value, {error, {91, invalid_string}}}

Raimo Niskanen-2
On Tue, Aug 15, 2017 at 11:09:05AM +0200, Ali Sabil wrote:
> Hi Khitai,
>
> That's because jiffy (mis)uses erlang:throw.

If it is so that jiffy:decode(Msg) throws {error,{91,invalid_string}}, then
it happens to be one way to return from a callback i.e to throw the value.

So, yes - if so jiffy misuses erlang:throw.  Jiffy should use erlang:error
if it is an error.

/ Raimo


>
> Best,
> Ali
>
> On Tue, Aug 15, 2017 at 5:13 AM, Khitai Pang <[hidden email]>
> wrote:
>
> > Hi Raimo, Attila,
> >
> > I have found out the cause: the handle_info callback of my gen_server
> > failed to decode a json string:
> >
> > {Json} = jiffy:decode(Msg),
> >
> > the above code generates {error, {91, invalid_string}}, and I believe
> > the error is caught by OTP gen_server code, and somehow the terminate()
> > function in OTP gen_server code complains about {bad_return_value,
> > {error, {91, invalid_string}}}.  Now I know the root cause of the
> > problem but I don't understand why it ends up in an error of
> > gen_server:terminate().
> >
> >
> > Best wishes,
> > Khitai
> >
> > On 2017/8/14 19:54, Attila Rajmund Nohl wrote:
> > > Hello!
> > >
> > > I'd check the code that handles the
> > > {basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>} message,
> > > because this was the last received message. Also my intuition is that
> > > somewhere your code expects a list of strings, but gets a simple
> > > string, and when it checks the first element, it finds 91 (probably
> > > the '[' character) instead of a string.
> > >
> > > 2017-08-14 5:17 GMT+02:00 Khitai Pang <[hidden email]>:
> > >> Hi list,
> > >>
> > >> On my CentOS7 server with esl-erlang-19.3.6-1.x86_64, a gen_server
> > >> process mysteriously crashes.  See the error info below.  I can't figure
> > >> out the reason of the error.  Any hint would be appreciated.
> > >>
> > >> {error_report,<0.25443.97>,
> > >>       {<0.28918.97>,crash_report,
> > >>        [[{initial_call,{xeef_analyzer,init,[Argument__1]}},
> > >>          {pid,<0.28918.97>},
> > >>          {registered_name,xeef_analyzer_009},
> > >>          {error_info,
> > >>              {exit,
> > >>                  {bad_return_value,{error,{91,invalid_string}}},
> > >> [{gen_server,terminate,7,[{file,"gen_server.erl"},{line,812}]},
> > >>                   {proc_lib,init_p_do_apply,3,
> > >>                       [{file,"proc_lib.erl"},{line,247}]}]}},
> > >>          {ancestors,[xeef_analyzer_sup,xeef_sup,<0.25310.97>]},
> > >> {messages,[{basic.cancel_ok,<<"amq.ctag-YRIyK1Kv0i93rkLbD9Zo8w">>}]},
> > >>          {links,
> > >> [#Port<0.2317500>,#Port<0.2317503>,<0.29009.97>,#Port<0.2317499>]},
> > >>          {dictionary,
> > >>              [{rand_seed,
> > >>                   {#{max => 18446744073709551615,next =>
> > >> #Fun<rand.4.41921595>,
> > >>                      type => exs1024,uniform => #Fun<rand.5.41921595>,
> > >>                      uniform_n => #Fun<rand.6.41921595>},
> > >>                    {[5529181756040335035,6774320120208346895,
> > >>                      4985297473998268992,12813505499546735856,
> > >>                      3059599059795068553,3134963973831305956,
> > >>                      5508046504858988103,3821329447243874404],
> > >>                     [6547380368325771448,16036002885223559991,
> > >>                      13982350927889545678,14401258729428095242,
> > >>                      6347438184782916914,10561027033563628251,
> > >>                      10847483533189471003,3486622809589930158]}}}]},
> > >>          {trap_exit,true},
> > >>          {status,running},
> > >>          {heap_size,987},
> > >>          {stack_size,27},
> > >>          {reductions,139726}],
> > >>         []]}}
> > >>
> > >>
> > >> {error_report,<0.25443.97>,
> > >>       {<0.29009.97>,supervisor_report,
> > >>        [{supervisor,{local,xeef_analyzer_sup}},
> > >>         {errorContext,child_terminated},
> > >>         {reason,{bad_return_value,{error,{91,invalid_string}}}},
> > >>         {offender,
> > >>             [{pid,<0.28918.97>},
> > >>              {id,xeef_analyzer},
> > >>              {mfargs,
> > >>                  {xeef_analyzer,start_link,
> > >> [{sandbox,{<0.28962.97>,<<"sanbox_queue">>},none,true}]}},
> > >>              {restart_type,permanent},
> > >>              {shutdown,5000},
> > >>              {child_type,worker}]}]}}
> > >>
> > >>
> > >>
> > >> Best wishes,
> > >> Khitai
> > >> _______________________________________________
> > >> erlang-questions mailing list
> > >> [hidden email]
> > >> http://erlang.org/mailman/listinfo/erlang-questions
> >
> > _______________________________________________
> > erlang-questions mailing list
> > [hidden email]
> > http://erlang.org/mailman/listinfo/erlang-questions
> >

> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions


--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions