From 2f56995f7c97e0da8bc63406a1fc42f43815135f Mon Sep 17 00:00:00 2001 From: Yang Yu Date: Wed, 10 Jan 2018 16:15:54 +0800 Subject: [PATCH] Fix InitGLOG glog will not hold ARGV[0] inside. --- paddle/framework/init.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/paddle/framework/init.cc b/paddle/framework/init.cc index e12bac1d78e..4ef82a541ef 100644 --- a/paddle/framework/init.cc +++ b/paddle/framework/init.cc @@ -11,6 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include // for strdup #include #include @@ -60,7 +61,9 @@ void InitDevices() { } void InitGLOG(const std::string &prog_name) { - google::InitGoogleLogging(prog_name.c_str()); + // glog will not hold the ARGV[0] inside. + // Use strdup to alloc a new string. + google::InitGoogleLogging(strdup(prog_name.c_str())); google::InstallFailureSignalHandler(); } -- GitLab