From c949ab72e4f9c72d38857ba86223bc828214e388 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 10 Mar 2016 19:40:20 +0000 Subject: [PATCH 1/4] Close read end of pipe after reading in gdb stack trace mode. --- src/os/unix/crashlog_unix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/os/unix/crashlog_unix.cpp b/src/os/unix/crashlog_unix.cpp index 175eb7c534..d8f95908b4 100644 --- a/src/os/unix/crashlog_unix.cpp +++ b/src/os/unix/crashlog_unix.cpp @@ -206,6 +206,8 @@ class CrashLogUnix : public CrashLog { } buffer += seprintf(buffer, last, "\n"); + close(pipefd[0]); /* close read end */ + int status; int wait_ret = waitpid(pid, &status, 0); if (wait_ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) { From a703e2ff58c82696cb46a48bb28cdb557d1dc0bc Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 21 Mar 2016 18:22:52 +0000 Subject: [PATCH 2/4] Increase verbosity of Pool assertion failure messages. --- src/core/pool_type.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index 4d20ed1abb..b73323c831 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -110,7 +110,7 @@ struct Pool : PoolBase { */ inline Titem *Get(size_t index) { - assert(index < this->first_unused); + assert_msg(index < this->first_unused, "index: %zu, first_unused: %zu, name: %s", index, this->first_unused, this->name); return this->data[index]; } @@ -166,7 +166,7 @@ struct Pool : PoolBase { { if (p == NULL) return; Titem *pn = (Titem *)p; - assert(pn == Tpool->Get(pn->index)); + assert_msg(pn == Tpool->Get(pn->index), "name: %s", Tpool->name); Tpool->FreeItem(pn->index); } @@ -200,7 +200,7 @@ struct Pool : PoolBase { * memory are the same (because of possible inheritance). * Use { size_t index = item->index; delete item; new (index) item; } * instead to make sure destructor is called and no memory leaks. */ - assert(ptr != Tpool->data[i]); + assert_msg(ptr != Tpool->data[i], "name: %s", Tpool->name); } return ptr; } From 6ed6eeb478500c446a890448d20f992f0e984ce7 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 21 Mar 2016 20:19:29 +0000 Subject: [PATCH 3/4] Include _current_company in crashlog AI config. --- src/crashlog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crashlog.cpp b/src/crashlog.cpp index ead0d96f3e..05ae410b67 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -172,7 +172,7 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const FontCache::Get(FS_MONO)->GetFontName() ); - buffer += seprintf(buffer, last, "AI Configuration (local: %i):\n", (int)_local_company); + buffer += seprintf(buffer, last, "AI Configuration (local: %i) (current: %i):\n", (int)_local_company, (int)_current_company); const Company *c; FOR_ALL_COMPANIES(c) { if (c->ai_info == NULL) { From 5359c43ec10284c44dda4a196a5ce2f01038c992 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 21 Mar 2016 20:33:55 +0000 Subject: [PATCH 4/4] Add scope logging for Vehicle::PreDestructor. --- src/vehicle.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 99347d8620..05f97e0f5c 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -741,6 +741,8 @@ void Vehicle::PreDestructor() { if (CleaningPool()) return; + SCOPE_INFO_FMT([this], "Vehicle::PreDestructor: %s", scope_dumper().VehicleInfo(this)); + if (Station::IsValidID(this->last_station_visited)) { Station *st = Station::Get(this->last_station_visited); st->loading_vehicles.remove(this);