質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
GDB

GDBはGNUソフトウェアシステムのための標準的なデバッガーです。

Q&A

解決済

1回答

1845閲覧

[gdbコマンド] Segmentation faultは何を意味しているのか知りたい。

退会済みユーザー

退会済みユーザー

総合スコア0

GDB

GDBはGNUソフトウェアシステムのための標準的なデバッガーです。

0グッド

0クリップ

投稿2022/04/23 02:14

編集2022/04/23 02:28

提示画面ですが実行するとSegmentation fault (core dumped)というエラーが出るのでデバッガで調べたのですが結果の意味を理解できません。これは何を意味しているのでしょうか? Main.cppを全てコメントアウトしても同じ現象が起きます。ソースファイルの保存もしました。

ソースコード全文 : https://54.gigafile.nu/0430-b11ef3ad0805dbde55d7d301a2f429006

環境

OS: ubuntu
利用ライブラリ opengl glew glfw,stb freetype

参考サイト:https://sunadarake.github.io/entry/2019/05/24/112315/

shigurechan@shigurechan-System-Product-Name:~/ドキュメント/FrameWork$ gdb Game GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: youshigurechan@shigurechan-System-Product-Name:~/ドキュメント/FrameWork$ gdb Game GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from Game... (gdb) run Starting program: /home/shigurechan/ドキュメント/FrameWork/Game [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/shigurechan/ドキュメント/FrameWork/Game [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from Game... (gdb) run Starting program: /home/shigurechan/ドキュメント/FrameWork/Game [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/shigurechan/ドキュメント/FrameWork/Game [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb)
Main.cpp

cpp

1#include <iostream> 2#include <GL/glew.h> 3#include <GLFW/glfw3.h> 4 5#include "../FrameWork/header/FrameWork.hpp" 6 7int main() 8{ 9 /* 10 if (glfwInit() == GL_FALSE) 11 { 12 std::cerr << "glfw を初期化出来ません。" << std::endl; 13 } 14 15 std::shared_ptr<FrameWork::Window> window = std::make_shared<FrameWork::Window>(glm::ivec2(640,480),"sample"); 16 FrameWork::SetCurrentWindowContext(window); 17 18 if (glewInit() != GLEW_OK) 19 { 20 std::cerr << "glew を初期化出来ません。" << std::endl; 21 } 22 23 while(*window) 24 { 25 26 27 28 29 30 31 32 window->SwapBuffer(); 33 } 34 35*/ 36 37 return 0; 38}
makefile

makeifle

1PRG :=Game 2SRC_DIR :=FrameWork/source 3SRC_USE_DIR :=source 4 5OBJ_DIR :=FrameWork/object 6OBJ_USE_DIR :=object 7 8DEP_DIR :=FrameWork/object 9DEP :=$(wildcard $(DEP_DIR)/*.d) 10 11SRC :=$(wildcard $(SRC_DIR)/*.cpp) 12SRC_USE :=$(wildcard $(SRC_USE_DIR)/*.cpp) 13 14OBJ :=$(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC)))) 15OBJ_USE :=$(addprefix $(OBJ_USE_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC_USE)))) 16 17$(PRG): $(OBJ) $(OBJ_USE) 18 $(CXX) $^ -o $@ -ldl -lGLESv2 -lGLU -lGL -lglfw3 -pthread -lGL -lGLEW -lfreetype -ldl -lX11 19 20$(OBJ_DIR)/%.o: FrameWork/source/%.cpp 21 $(CXX) -g -c -MMD -MP $< -o $@ 22-include $(DEP) 23 24$(OBJ_USE_DIR)/%.o: source/%.cpp 25 $(CXX) -g -c -MMD -MP $< -o $@ 26-include $(DEP) 27 28 29 30 31clean: 32 rm -f ./$(OBJ_USE_DIR)/*.o ./$(OBJ_DIR)/*.o *.out ./$(OBJ_DIR)/*.d ./$(OBJ_USE_DIR)/*.d $(PRG) 33

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

Segmentation faultは何を意味しているのか知りたい。

コードの中でアクセス違反があるとそうなります
例えば配列の範囲外のアクセスとか、未初期化のポインタ、間違ったアドレスを設定したポインタのアクセスを探してみることですね

で、注意すべきは、そのアクセス違反が起きたところでそいつが発生するとは限らない、ってことですねー

投稿2022/04/23 10:39

y_waiwai

総合スコア87774

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2022/04/23 10:51

externでスマートポインタのクラス型の変数がありそれを初期化時にインスタンスを生成していたためでした。 質問ですがexternはstatic 変数のようにmainの前に呼ばれるのでしょうか?
y_waiwai

2022/04/23 23:45

コードを見ないとなんと見えませんが、初期化処理はmainの前に実行されますね
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問