eddic / fastcgipp

fastcgi++: A C++ FastCGI and Web development platform:
https://fastcgipp.isatec.ca
GNU Lesser General Public License v3.0
310 stars 94 forks source link

Pure function called in fcgistreambuf_test #60

Closed delperugia closed 5 years ago

delperugia commented 5 years ago

Using gcc 7.3.0 on Ubuntu 18.04 (32 and 64 bits), the fcgistreambuf_test program throws a "pure virtual method called" error when the destructor of streambuf is called. gdb shows:

#5  0x00007ffff77d980f in __cxa_pure_virtual () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x000055555555be95 in Fastcgipp::WebStreambuf<wchar_t, std::char_traits<wchar_t> >::sync (
    this=0x7fffffff6340)
    at ../fastcgipp/include/fastcgi++/webstreambuf.hpp:229
#7  0x000055555555ba36 in Fastcgipp::WebStreambuf<wchar_t, std::char_traits<wchar_t> >::~WebStreambuf (
    this=0x7fffffff6340, __in_chrg=<optimized out>)
    at ../fastcgipp/include/fastcgi++/webstreambuf.hpp:240
#8  0x000055555555c428 in Fastcgipp::FcgiStreambuf<wchar_t, std::char_traits<wchar_t> >::~FcgiStreambuf (
    this=0x7fffffff6340, __in_chrg=<optimized out>)
    at ../fastcgipp/include/fastcgi++/fcgistreambuf.hpp:55
#9  0x000055555555a99e in main () at ../fastcgipp/tests/fcgistreambuf.cpp:312

It seems it is because base class WebStreambuf destructor calls sync which calls emptyBuffer which is a pure function defined in the parent class FcgiStreambuf. And since destructors are called in sequence, FcgiStreambuf is already destroyed when WebStreambuf destructor is executed.

Was working fine in previous versions where sync was called from FcgiStreambuf destructor (tested with commit 3bf169a).

eddic commented 5 years ago

Whooops. Thanks for catching this.