質問編集履歴
5
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
##### 確認したこと
|
6
6
|
逐次実行でFrameWork::LoadTexture()関数が原因であることが判明 ※コメントアウトして実行して確認
|
7
7
|
画像ファイルが読み込まれていること。画像ファイルが存在していることを確認
|
8
|
-
参考サイトより
|
8
|
+
参考サイトAより
|
9
9
|
日本語訳
|
10
10
|
```
|
11
11
|
エラーを検索すると、Cプログラミングでよくあるエラーであることがわかります。プログラムが割り当てられたメモリ(文字列や動的配列、または自分で割り当てたもの)で範囲外になっていることを意味しているようです。(ただし、-exxがキャッチしない場合は、おそらく配列ではありません。)
|
@@ -14,11 +14,13 @@
|
|
14
14
|
-gを指定してコンパイルし、gdbにロードしてプログラムを「実行」すると、その時点で停止し、行番号が表示されるか、バックトレース(「bt」)してどの関数を確認できるかがわかります。コードが実行されていました。
|
15
15
|
```
|
16
16
|
とあるのですがbtコマンドでトレースしました。
|
17
|
-
|
17
|
+
LoadTexture()関数の//stbi_image_free(texture.data);のコメントアウトを解除してDeleteTexture() 関数の//stbi_image_free(texture.data);をコメントアウトすると`double free or corruption (!prev)` というエラーが出ます。
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
-
参考サイト:https://www.freebasic.net/forum/viewtopic.php?t=29372#:~:text=Re%3A%20malloc()%3A%20invalid%20size%20(unsorted)&text=It%20looks%20like%20it%20means,able%20to%20tell%20you%20more.
|
21
|
+
参考サイトA:https://www.freebasic.net/forum/viewtopic.php?t=29372#:~:text=Re%3A%20malloc()%3A%20invalid%20size%20(unsorted)&text=It%20looks%20like%20it%20means,able%20to%20tell%20you%20more.
|
22
|
+
参考サイトB: https://stackoverflow.com/questions/2902064/how-to-track-down-a-double-free-or-corruption-error
|
23
|
+
|
22
24
|
##### コンソール画面
|
23
25
|
```
|
24
26
|
$ ./Game
|
@@ -174,6 +176,18 @@
|
|
174
176
|
|
175
177
|
}
|
176
178
|
|
179
|
+
|
180
|
+
|
181
|
+
// ##################################### テクスチャを削除 #####################################
|
182
|
+
void FrameWork::DeleteTexture(FrameWork::Texture texture)
|
183
|
+
{
|
184
|
+
glDeleteTextures(1,&texture.ID);
|
185
|
+
//stbi_image_free(texture.data);
|
186
|
+
//texture.data = NULL;
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
177
191
|
```
|
178
192
|
|
179
193
|
##### Genrate_Dungeon.cpp
|
4
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,8 +5,20 @@
|
|
5
5
|
##### 確認したこと
|
6
6
|
逐次実行でFrameWork::LoadTexture()関数が原因であることが判明 ※コメントアウトして実行して確認
|
7
7
|
画像ファイルが読み込まれていること。画像ファイルが存在していることを確認
|
8
|
+
参考サイトより
|
9
|
+
日本語訳
|
10
|
+
```
|
11
|
+
エラーを検索すると、Cプログラミングでよくあるエラーであることがわかります。プログラムが割り当てられたメモリ(文字列や動的配列、または自分で割り当てたもの)で範囲外になっていることを意味しているようです。(ただし、-exxがキャッチしない場合は、おそらく配列ではありません。)
|
12
|
+
|
13
|
+
gdbなどのデバッガーで詳細を確認できるはずです。
|
14
|
+
-gを指定してコンパイルし、gdbにロードしてプログラムを「実行」すると、その時点で停止し、行番号が表示されるか、バックトレース(「bt」)してどの関数を確認できるかがわかります。コードが実行されていました。
|
15
|
+
```
|
16
|
+
とあるのですがbtコマンドでトレースしました。
|
8
17
|
|
9
18
|
|
19
|
+
|
20
|
+
|
21
|
+
参考サイト:https://www.freebasic.net/forum/viewtopic.php?t=29372#:~:text=Re%3A%20malloc()%3A%20invalid%20size%20(unsorted)&text=It%20looks%20like%20it%20means,able%20to%20tell%20you%20more.
|
10
22
|
##### コンソール画面
|
11
23
|
```
|
12
24
|
$ ./Game
|
3
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
提示コードなのですが画像を読み込むコードで以下のコンソール画面の実行時エラーが発生します。なぜ`invalid size`になるのでしょうか?`prite = FrameWork::LoadTexture("asset/texture/brickChip.png");` をコメントアウトすると実行できるためこの関数が原因なのでは事実です。
|
1
|
+
提示コードなのですが画像を読み込むコードで以下のコンソール画面の実行時エラーが発生します。なぜ`invalid size`になるのでしょうか?`prite = FrameWork::LoadTexture("asset/texture/brickChip.png");` をコメントアウトすると実行できるためこの関数が原因なのでは事実です。メモリ確保エラーのメッセージと思われます。
|
2
|
+
|
3
|
+
|
2
4
|
|
3
5
|
##### 確認したこと
|
4
6
|
逐次実行でFrameWork::LoadTexture()関数が原因であることが判明 ※コメントアウトして実行して確認
|
5
7
|
画像ファイルが読み込まれていること。画像ファイルが存在していることを確認
|
6
8
|
|
7
|
-
参考サイト:https://stackoverflow.com/questions/62205404/why-do-i-get-the-error-malloc-invalid-size-unsorted
|
8
9
|
|
9
10
|
##### コンソール画面
|
10
11
|
```
|
2
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,26 +78,7 @@
|
|
78
78
|
#28 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Game, std::allocator<Game>>(Game*&, std::_Sp_alloc_shared_tag<std::allocator<Game> >) (__a=..., __p=<optimized out>, this=<optimized out>)
|
79
79
|
at /usr/include/c++/9/bits/shared_ptr_base.h:679
|
80
80
|
#29 std::__shared_ptr<Game, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<Game>>(std::_Sp_alloc_shared_tag<std::allocator<Game> >) (__tag=..., this=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:1344
|
81
|
-
|
82
|
-
__tag=..., this=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:359
|
83
|
-
#31 std::allocate_shared<Game, std::allocator<Game>>(std::allocator<Game> const&) (__a=...)
|
84
|
-
at /usr/include/c++/9/bits/shared_ptr.h:702
|
85
|
-
#32 std::make_shared<Game> () at /usr/include/c++/9/bits/shared_ptr.h:718
|
86
|
-
#33 Entry::Entry (this=0x555555e636e0) at source/Entry.cpp:7
|
87
|
-
#34 0x000055555555e884 in __gnu_cxx::new_allocator<Entry>::construct<Entry> (this=<optimized out>,
|
88
|
-
__p=0x555555e636e0) at /usr/include/c++/9/new:174
|
89
|
-
#35 std::allocator_traits<std::allocator<Entry> >::construct<Entry> (__a=..., __p=0x555555e636e0)
|
90
|
-
at /usr/include/c++/9/bits/alloc_traits.h:483
|
91
|
-
#36 std::_Sp_counted_ptr_inplace<Entry, std::allocator<Entry>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator<Entry>) (__a=..., this=0x555555e636d0) at /usr/include/c++/9/bits/shared_ptr_base.h:548
|
92
|
-
#37 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Entry, std::allocator<Entry>>(Entry*&, std::_Sp_alloc_shared_tag<std::allocator<Entry> >) (__a=..., __p=<synthetic pointer>: <optimized out>, this=<synthetic pointer>)
|
93
|
-
at /usr/include/c++/9/bits/shared_ptr_base.h:679
|
94
|
-
#38 std::__shared_ptr<Entry, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<Entry>>(std::_Sp_alloc_shared_tag<std::allocator<Entry> >) (__tag=..., this=<synthetic pointer>) at /usr/include/c++/9/bits/shared_ptr_base.h:1344
|
95
|
-
#39 std::shared_ptr<Entry>::shared_ptr<std::allocator<Entry>>(std::_Sp_alloc_shared_tag<std::allocator<Entry> >) (
|
96
|
-
__tag=..., this=<synthetic pointer>) at /usr/include/c++/9/bits/shared_ptr.h:359
|
97
|
-
#40 std::allocate_shared<Entry, std::allocator<Entry>>(std::allocator<Entry> const&) (__a=...)
|
98
|
-
at /usr/include/c++/9/bits/shared_ptr.h:702
|
99
|
-
#41 std::make_shared<Entry> () at /usr/include/c++/9/bits/shared_ptr.h:718
|
100
|
-
#42 main () at source/Main.cpp:30
|
81
|
+
|
101
82
|
(gdb)
|
102
83
|
|
103
84
|
|
@@ -181,3 +162,20 @@
|
|
181
162
|
}
|
182
163
|
|
183
164
|
```
|
165
|
+
|
166
|
+
##### Genrate_Dungeon.cpp
|
167
|
+
```cpp
|
168
|
+
|
169
|
+
Generate_Dungeon::Generate_Dungeon()
|
170
|
+
{
|
171
|
+
area.resize(0);
|
172
|
+
area.push_back(Area { 100 * 100,glm::ivec2(0,0),glm::ivec2(100,100) });
|
173
|
+
|
174
|
+
}
|
175
|
+
/*
|
176
|
+
文字数の関係で省略
|
177
|
+
|
178
|
+
*/
|
179
|
+
```
|
180
|
+
|
181
|
+
|
1
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
提示コードなのですが画像を読み込むコードで以下のコンソール画面の実行時エラーが発生します。なぜ`invalid size`になるのでしょうか?`prite = FrameWork::LoadTexture("asset/texture/brickChip.png");` をコメントアウトすると実行できるためこの関数が原因なのでは事実です。
|
2
|
+
|
3
|
+
##### 確認したこと
|
4
|
+
逐次実行でFrameWork::LoadTexture()関数が原因であることが判明 ※コメントアウトして実行して確認
|
5
|
+
画像ファイルが読み込まれていること。画像ファイルが存在していることを確認
|
2
6
|
|
3
7
|
参考サイト:https://stackoverflow.com/questions/62205404/why-do-i-get-the-error-malloc-invalid-size-unsorted
|
4
8
|
|