rstudio / httpuv

HTTP and WebSocket server package for R
Other
227 stars 86 forks source link

Error found by Valgrind #213

Closed wch closed 5 years ago

wch commented 5 years ago

On CRAN, valgrind turns up the following error about Syscall param epoll_ctl(event) points to uninitialised byte(s). It appears to be an issue with the version of libuv we're using and will require a libuv update.

https://github.com/libuv/libuv/commit/0813f5b97afe086a7b4d827774605b1f2e99191c#diff-ef6a692d0a1d5779d26d4f57afcf3d42

==41164== Memcheck, a memory error detector
==41164== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==41164== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==41164== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R -f testthat.R --restore --save --no-readline --vanilla
==41164== 

R Under development (unstable) (2019-03-25 r76268) -- "Unsuffered Consequences"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(testthat)
> library(httpuv)
> 
> test_check("httpuv")
==41164== Thread 2:
==41164== Syscall param epoll_ctl(event) points to uninitialised byte(s)
==41164==    at 0x7C4C8EA: epoll_ctl (in /usr/lib64/libc-2.27.so)
==41164==    by 0x18BDCC98: uv__io_poll (packages/tests-vg/httpuv/src/libuv/src/unix/linux-core.c:242)
==41164==    by 0x18BD31C4: uv_run (packages/tests-vg/httpuv/src/libuv/src/unix/core.c:370)
==41164==    by 0x18BA1600: io_thread(void*) (packages/tests-vg/httpuv/src/httpuv.cpp:134)
==41164==    by 0x793A593: start_thread (in /usr/lib64/libpthread-2.27.so)
==41164==    by 0x7C4BF4E: clone (in /usr/lib64/libc-2.27.so)
==41164==  Address 0x1d07cbdc is on thread 2's stack
==41164==  in frame #1, created by uv__io_poll (linux-core.c:189)
==41164==  Uninitialised value was created by a stack allocation
==41164==    at 0x18BDCBCE: uv__io_poll (packages/tests-vg/httpuv/src/libuv/src/unix/linux-core.c:189)
==41164== 
══ testthat results  ═══════════════════════════════════════════════════════════
OK: 195 SKIPPED: 8 FAILED: 0
> 
> proc.time()
   user  system elapsed 
 69.328   1.217  69.467 
==41164== 
==41164== HEAP SUMMARY:
==41164==     in use at exit: 97,405,820 bytes in 19,200 blocks
==41164==   total heap usage: 203,104 allocs, 183,904 frees, 284,954,155 bytes allocated
==41164== 
==41164== Thread 1:
==41164== 8 bytes in 1 blocks are definitely lost in loss record 8 of 2,050
==41164==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==41164==    by 0x18B977A6: HttpRequest::_initializeEnv() (packages/tests-vg/httpuv/src/httprequest.cpp:161)
==41164==    by 0x18B8D971: operator() (R-devel/site-library/BH/include/boost/function/function_template.hpp:763)
==41164==    by 0x18B8D971: operator() (packages/tests-vg/httpuv/src/callback.h:29)
==41164==    by 0x18B8D971: invoke_callback(void*) (packages/tests-vg/httpuv/src/callback.cpp:7)
==41164==    by 0x18730623: operator() (R-devel/site-library/BH/include/boost/function/function_template.hpp:763)
==41164==    by 0x18730623: operator() (/tmp/RtmpBmnR5t/R.INSTALLb878733d980d/later/src/callback_registry.h:26)
==41164==    by 0x18730623: execCallbacks(double, bool) (/tmp/RtmpBmnR5t/R.INSTALLb878733d980d/later/src/later.cpp:98)
==41164==    by 0x1872266B: _later_execCallbacks (/tmp/RtmpBmnR5t/R.INSTALLb878733d980d/later/src/RcppExports.cpp:35)
==41164==    by 0x495D03: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==41164==    by 0x4C891F: bcEval (svn/R-devel/src/main/eval.c:6765)
==41164==    by 0x4D8BFF: Rf_eval (svn/R-devel/src/main/eval.c:620)
==41164==    by 0x4DA7AE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==41164==    by 0x4DB504: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==41164==    by 0x4D1CCC: bcEval (svn/R-devel/src/main/eval.c:6733)
==41164==    by 0x4D8BFF: Rf_eval (svn/R-devel/src/main/eval.c:620)
==41164== 
==41164== 352 bytes in 1 blocks are possibly lost in loss record 138 of 2,050
==41164==    at 0x4C3114A: calloc (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:762)
==41164==    by 0x4011991: allocate_dtv (in /usr/lib64/ld-2.27.so)
==41164==    by 0x401230D: _dl_allocate_tls (in /usr/lib64/ld-2.27.so)
==41164==    by 0x793B1A5: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.27.so)
==41164==    by 0x18BDA79D: uv_thread_create (packages/tests-vg/httpuv/src/libuv/src/unix/thread.c:202)
==41164==    by 0x18BA0E64: ensure_io_thread() (packages/tests-vg/httpuv/src/httpuv.cpp:155)
==41164==    by 0x18BA2D79: makeTcpServer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>) (packages/tests-vg/httpuv/src/httpuv.cpp:263)
==41164==    by 0x18B8B329: _httpuv_makeTcpServer (packages/tests-vg/httpuv/src/RcppExports.cpp:48)
==41164==    by 0x49578F: R_doDotCall (svn/R-devel/src/main/dotcode.c:606)
==41164==    by 0x495D03: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==41164==    by 0x4C891F: bcEval (svn/R-devel/src/main/eval.c:6765)
==41164==    by 0x4D8BFF: Rf_eval (svn/R-devel/src/main/eval.c:620)
==41164== 
==41164== 757 (216 direct, 541 indirect) bytes in 1 blocks are definitely lost in loss record 193 of 2,050
==41164==    at 0x4C2F4B6: operator new(unsigned long) (/builddir/build/BUILD/valgrind-3.14.0/coregrind/m_replacemalloc/vg_replace_malloc.c:344)
==41164==    by 0x18BB27ED: allocate (/usr/include/c++/8/ext/new_allocator.h:111)
==41164==    by 0x18BB27ED: allocate (/usr/include/c++/8/bits/alloc_traits.h:436)
==41164==    by 0x18BB27ED: _M_get_node (/usr/include/c++/8/bits/stl_tree.h:599)
==41164==    by 0x18BB27ED: _M_create_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, StaticPath> > (/usr/include/c++/8/bits/stl_tree.h:653)
==41164==    by 0x18BB27ED: std::pair<std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, StaticPath> >, bool> std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, StaticPath>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, StaticPath> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, StaticPath> > >::_M_emplace_unique<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, StaticPath> >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, StaticPath>&&) (/usr/include/c++/8/bits/stl_tree.h:2367)
==41164==    by 0x18BB0ABC: insert<std::pair<std::__cxx11::basic_string<char>, StaticPath> > (/usr/include/c++/8/bits/stl_map.h:815)
==41164==    by 0x18BB0ABC: StaticPathManager::StaticPathManager(Rcpp::Vector<19, Rcpp::PreserveStorage> const&, Rcpp::Vector<19, Rcpp::PreserveStorage> const&) (packages/tests-vg/httpuv/src/staticpath.cpp:219)
==41164==    by 0x18BB6956: RWebApplication::RWebApplication(Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>) (packages/tests-vg/httpuv/src/webapplication.cpp:275)
==41164==    by 0x18BA2C94: makeTcpServer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Function_Impl<Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>) (packages/tests-vg/httpuv/src/httpuv.cpp:259)
==41164==    by 0x18B8B329: _httpuv_makeTcpServer (packages/tests-vg/httpuv/src/RcppExports.cpp:48)
==41164==    by 0x49578F: R_doDotCall (svn/R-devel/src/main/dotcode.c:606)
==41164==    by 0x495D03: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==41164==    by 0x4C891F: bcEval (svn/R-devel/src/main/eval.c:6765)
==41164==    by 0x4D8BFF: Rf_eval (svn/R-devel/src/main/eval.c:620)
==41164==    by 0x4DA7AE: R_execClosure (svn/R-devel/src/main/eval.c:1780)
==41164==    by 0x4DB504: Rf_applyClosure (svn/R-devel/src/main/eval.c:1706)
==41164== 
==41164== LEAK SUMMARY:
==41164==    definitely lost: 224 bytes in 2 blocks
==41164==    indirectly lost: 541 bytes in 3 blocks
==41164==      possibly lost: 352 bytes in 1 blocks
==41164==    still reachable: 97,404,703 bytes in 19,194 blocks
==41164==         suppressed: 0 bytes in 0 blocks
==41164== Reachable blocks (those to which a pointer was found) are not shown.
==41164== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==41164== 
==41164== For counts of detected and suppressed errors, rerun with: -v
==41164== ERROR SUMMARY: 175 errors from 4 contexts (suppressed: 0 from 0)
wch commented 5 years ago

This was closed by #214.