동적으로로드 된 라이브러리를 사용하는 큰 응용 프로그램이 있습니다. 프로그램을 끝낼 때 프로그램을 종료 할 때 "glibc가 손상된 이중 연결 목록을 발견했습니다"라는 메시지를 segfaults 또는 spits합니다. 하자 우리는 세 개의 파일이 있다고 가정 : 다음 Valgrind의 출력을 보면 나는이 사건이 무엇인지 생각gcc, C++ : 정적 문자열 멤버 가변성 힙 손상/분할 오류 발생
utilities.c - compiled with -fPIC and used ar and ranlib to create utilities.a.
dynamicallyloaded.c- compiled with -fPIC and -shared and linked with utlities.a to generate dynamicallyloaded.so
main.c - compiled with -fPIC and linked with utilities.a to create main. main dynamically loads and uses dynamicallyloaded.so .
utilities.h - delclared a class IfTrackerFile with AubFileName as a static string member like static string AubFileName;
utilities.cpp - defines the static variable: string IfTrackerFile::AubFileName;
Valgrind의 아웃 무료 무효가 있음// 삭제 라인에 삭제 말한다 : 문자열 IfTrackerFile :: AubFileName;
실마리가 없습니다. 이와 관련하여 도움/방향에 진심으로 감사드립니다.
정적 라이브러리 사용은 간단하지 않습니다. 공유 라이브러리로 모든 것을 컴파일하고 컴파일러가 그것을 정렬합니다. –