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

Encoding::UndefinedConversionError #3

Closed
cookiebody opened this issue Dec 25, 2013 · 0 comments
Closed

Encoding::UndefinedConversionError #3

cookiebody opened this issue Dec 25, 2013 · 0 comments

Comments

@cookiebody
Copy link

Ruby 2.1 + Padrino + Unicorn

E, [2013-12-26T10:47:11.015221 #6659] ERROR -- : app error: "\xE8" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
E, [2013-12-26T10:47:11.015368 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/bundler/gems/stackprof-dba6d3d8a44e/lib/stackprof/middleware.rb:36:in `write'
E, [2013-12-26T10:47:11.015415 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/bundler/gems/stackprof-dba6d3d8a44e/lib/stackprof/middleware.rb:36:in `block in save'
E, [2013-12-26T10:47:11.015465 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/bundler/gems/stackprof-dba6d3d8a44e/lib/stackprof/middleware.rb:35:in `open'
E, [2013-12-26T10:47:11.015513 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/bundler/gems/stackprof-dba6d3d8a44e/lib/stackprof/middleware.rb:35:in `save'
E, [2013-12-26T10:47:11.015559 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/bundler/gems/stackprof-dba6d3d8a44e/lib/stackprof/middleware.rb:23:in `call'
E, [2013-12-26T10:47:11.015605 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
E, [2013-12-26T10:47:11.015659 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
E, [2013-12-26T10:47:11.015705 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb:18:in `call'
E, [2013-12-26T10:47:11.015750 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb:16:in `call'
E, [2013-12-26T10:47:11.015794 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb:18:in `call'
E, [2013-12-26T10:47:11.015838 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
E, [2013-12-26T10:47:11.015883 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
E, [2013-12-26T10:47:11.015927 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb:31:in `call'
E, [2013-12-26T10:47:11.015971 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
E, [2013-12-26T10:47:11.016016 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
E, [2013-12-26T10:47:11.016066 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/sinatra-1.4.3/lib/sinatra/base.rb:1949:in `call'
E, [2013-12-26T10:47:11.016111 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/sinatra-1.4.3/lib/sinatra/base.rb:1449:in `block in call'
E, [2013-12-26T10:47:11.016156 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/sinatra-1.4.3/lib/sinatra/base.rb:1726:in `synchronize'
E, [2013-12-26T10:47:11.016200 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/sinatra-1.4.3/lib/sinatra/base.rb:1449:in `call'
E, [2013-12-26T10:47:11.016245 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/padrino-core-0.11.3/lib/padrino-core/router.rb:83:in `block in call'
E, [2013-12-26T10:47:11.016289 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/padrino-core-0.11.3/lib/padrino-core/router.rb:76:in `each'
E, [2013-12-26T10:47:11.016333 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/padrino-core-0.11.3/lib/padrino-core/router.rb:76:in `call'
E, [2013-12-26T10:47:11.016377 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:552:in `process_client'
E, [2013-12-26T10:47:11.016421 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-worker-killer-0.4.2/lib/unicorn/worker_killer.rb:51:in `process_client'
E, [2013-12-26T10:47:11.016466 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-worker-killer-0.4.2/lib/unicorn/worker_killer.rb:124:in `process_client'
E, [2013-12-26T10:47:11.016511 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.6.3/lib/unicorn/oob_gc.rb:60:in `process_client'
E, [2013-12-26T10:47:11.016555 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:632:in `worker_loop'
E, [2013-12-26T10:47:11.016605 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/newrelic_rpm-3.6.7.159/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:22:in `call'
E, [2013-12-26T10:47:11.016656 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/newrelic_rpm-3.6.7.159/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:22:in `block (4 levels) in <top (required)>'
E, [2013-12-26T10:47:11.016701 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
E, [2013-12-26T10:47:11.016751 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:142:in `start'
E, [2013-12-26T10:47:11.016796 #6659] ERROR -- : /usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.6.3/bin/unicorn:126:in `<top (required)>'
E, [2013-12-26T10:47:11.016840 #6659] ERROR -- : /usr/local/bin/unicorn:23:in `load'
E, [2013-12-26T10:47:11.016884 #6659] ERROR -- : /usr/local/bin/unicorn:23:in `<main>'
@tmm1 tmm1 closed this as completed in 77fbd2e Dec 25, 2013
XrXr added a commit to XrXr/stackprof that referenced this issue Dec 10, 2024
I got a SEGV core dump with the stack trace as follows:

    #0  __pthread_kill_implementation (no_tid=0, signo=14, threadid=0) at ./nptl/pthread_kill.c:50
    tmm1#1  __pthread_kill_internal (signo=14, threadid=0) at ./nptl/pthread_kill.c:78
    tmm1#2  __GI___pthread_kill (threadid=0, signo=14) at ./nptl/pthread_kill.c:89
    tmm1#3  <signal handler called> () at /lib/x86_64-linux-gnu/libc.so.6
    tmm1#4  stackprof_start (argc=<optimized out>, argv=<optimized out>, self=<optimized out>) at stackprof.c:228
    tmm1#5  vm_call_cfunc_with_frame_
    ...

Notice that `threadid=0` in the top frame -- the SEGV comes from inside
libc as it tries to dereference `threadid`.

The signal comes from stackprof's signal handler:

    if (pthread_self() != _stackprof.target_thread) {
        pthread_kill(_stackprof.target_thread, sig);
        return;
    }

During stackprof_start(), `_stackprof.target_thread` is 0.

You can recreate the stack trace in the crash with a program that does
`pthread_kill(0, SIGALRM)`:

    #include <signal.h>

    int
    main(void)
    {
       pthread_kill(0, SIGALRM);
    }

Only set `running` after target_thread is set to avoid this crash in
case the timer expires after `settimer()` but before setting
`target_thread`.

Also, since the ordering is important here, make `running`
`volatile sig_atomic_t` to prevent the compiler from doing unwanted
reordering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant