我在這裏遇到了問題。調用SDL_SetVideoMode時出現分段錯誤
我是一個組的一部分,我們正在使用SDL進行圖形處理。當我運行我們的test_SDL.cc程序(只是爲了查看所有設置正確)時,我是唯一一個出現分段錯誤的人。
下面是相關代碼:
int main(int argc, char** arg)
{
// Initializing
if(-1 == SDL_Init(SDL_INIT_EVERYTHING))
return 1;
SDL_Surface* screen{nullptr};
SDL_Surface* hello{nullptr};
screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
...
}
當SDL_SetVideoMode(...)執行我得到的分割故障。任何可能的線索?
我在Mac OS上運行的小牛隊,並與終端
Pingul % gcc-mp-4.8 -lstdc++ -std=c++11 -Wall -Wpedantic `sdl-config --cflags --libs` test_SDL.cc
編譯如果它可以有所作爲的其他所有在我的組使用的Ubuntu。感謝所有幫助!
編輯: 崩潰關係 過程:a.out的[918] 路徑:/Users/USER/Documents/*/a.out 標識符:a.out的 版本:0 編碼類型:X86-64 (母語) 父進程:zsh的[297] 負責:端子[155] 用戶ID:501
Date/Time: 2013-12-08 21:30:32.860 +0100
OS Version: Mac OS X 10.9 (13A603)
Report Version: 11
Anonymous UUID: EF22B2C8-6B58-F80F-184F-61D6ECE0B474
Crashed Thread: 1
Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Thread 0:: Dispatch queue: com.apple.main-thread
0 libSDL-1.2.0.dylib 0x000000010d59c3a9 -[SDL_QuartzWindow display] + 33
1 com.apple.AppKit 0x00007fff9460a681 __67-[NSWindow _updateSettingsSendingScreenChangeNotificationIfNeeded:]_block_invoke + 237
2 com.apple.AppKit 0x00007fff9460a548 NSPerformWithScreenUpdatesDisabled + 65
3 com.apple.AppKit 0x00007fff9460a4f7 -[NSWindow _updateSettingsSendingScreenChangeNotificationIfNeeded:] + 197
4 com.apple.AppKit 0x00007fff946027e1 -[NSWindow _setFrame:updateBorderViewSize:] + 914
5 com.apple.AppKit 0x00007fff94601d5e -[NSWindow _oldPlaceWindow:] + 652
6 com.apple.AppKit 0x00007fff9460118c -[NSWindow _setFrameCommon:display:stashSize:] + 1633
7 com.apple.AppKit 0x00007fff946155bc -[NSWindow setFrameOrigin:] + 369
8 com.apple.AppKit 0x00007fff9483d561 -[NSWindow center] + 278
9 libSDL-1.2.0.dylib 0x000000010d59a386 QZ_SetVideoMode + 1652
10 libSDL-1.2.0.dylib 0x000000010d5915a9 SDL_SetVideoMode + 906
11 a.out 0x000000010d46c7d4 SDL_main + 203
12 a.out 0x000000010d46c0bb -[SDLMain applicationDidFinishLaunching:] + 49
13 com.apple.CoreFoundation 0x00007fff935c7fcc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
14 com.apple.CoreFoundation 0x00007fff934bbc5d _CFXNotificationPost + 2893
15 com.apple.Foundation 0x00007fff9419d4aa -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
16 com.apple.AppKit 0x00007fff944e7b79 -[NSApplication _postDidFinishNotification] + 289
17 com.apple.AppKit 0x00007fff944e78ac -[NSApplication _sendFinishLaunchingNotification] + 195
18 com.apple.AppKit 0x00007fff944e4796 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 570
19 com.apple.AppKit 0x00007fff944e41eb -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 242
20 com.apple.Foundation 0x00007fff941bbeaa -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
21 com.apple.Foundation 0x00007fff941bbd1d _NSAppleEventManagerGenericHandler + 106
22 com.apple.AE 0x00007fff8de11e1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381
23 com.apple.AE 0x00007fff8de11c32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
24 com.apple.AE 0x00007fff8de11b36 aeProcessAppleEvent + 315
25 com.apple.HIToolbox 0x00007fff8e0a55f1 AEProcessAppleEvent + 56
26 com.apple.AppKit 0x00007fff944e00f6 _DPSNextEvent + 1026
27 com.apple.AppKit 0x00007fff944df8db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
28 com.apple.AppKit 0x00007fff944d39cc -[NSApplication run] + 553
29 a.out 0x000000010d46c6df main + 1305
30 libdyld.dylib 0x00007fff936a05fd start + 1
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x00007fff8a4c4e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93697f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff9369afb9 start_wqthread + 13
Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8a4c5662 kevent64 + 10
1 libdispatch.dylib 0x00007fff8e52343d _dispatch_mgr_invoke + 239
2 libdispatch.dylib 0x00007fff8e523152 _dispatch_mgr_thread + 52
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8a4c4e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93697f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff9369afb9 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff8a4c4e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93697f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff9369afb9 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff8a4c4e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93697f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff9369afb9 start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff8a4c4e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93697f08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff9369afb9 start_wqthread + 13
Thread 1 crashed with X86 Thread State (64-bit):
rax: 0x0000000002000170 rbx: 0x000000010e081000 rcx: 0x000000010e080f28 rdx: 0x0000000000000000
rdi: 0x0000000000000004 rsi: 0x0000000000000000 rbp: 0x000000010e080f50 rsp: 0x000000010e080f28
r8: 0x00007fff922df8d7 r9: 0x0000000000000164 r10: 0x0000000000000000 r11: 0x0000000000000246
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000070001 r15: 0x0000000000001003
rip: 0x00007fff8a4c4e6a rfl: 0x0000000000000246 cr2: 0x000000010f352000
Logical CPU: 0
Error Code: 0x02000170
Trap Number: 133
並且還
VM Region Summary:
ReadOnly portion of Libraries: Total=155.7M resident=54.7M(35%) swapped_out_or_unallocated=101.0M(65%)
Writable regions: Total=71.8M written=2836K(4%) resident=3764K(5%) swapped_out=0K(0%) unallocated=68.1M( 95%)
REGION TYPE VIRTUAL
=========== =======
CG image 4K
CG shared images 212K
Dispatch continuations 8192K
Kernel Alloc Once 8K
MALLOC 36.6M
MALLOC (admin) 32K
Memory Tag 242 12K
STACK GUARD 56.0M
Stack 10.6M
VM_ALLOCATE 16.3M
__DATA 19.3M
__IMAGE 528K
__LINKEDIT 66.1M
__TEXT 89.6M
__UNICODE 544K
mapped file 28.2M
shared memory 4K
=========== =======
TOTAL 332.2M
Model: MacBookAir4,1, BootROM MBA41.0077.B0F, 2 processors, Intel Core i5, 1.6 GHz, 4 GB, SMC 1.74f4
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In, 384 MB
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1333 MHz, 0x80AD, 0x484D54333235533642465238432D48392020
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1333 MHz, 0x80AD, 0x484D54333235533642465238432D48392020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xE9), Broadcom BCM43xx 1.0 (5.106.98.100 .22)
Bluetooth: Version 4.2.0f6 12982, 3 services, 23 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD TS128C, 121,33 GB
USB Device: FaceTime Camera (Built-in)
USB Device: Hub
USB Device: Apple Internal Keyboard/Trackpad
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
USB Device: Hub
Thunderbolt Bus: MacBook Air, Apple Inc., 8.1
我希望這是相關的信息。請告訴我,如果我格式化這個怪異以及。
你/你的小組成員正在使用什麼版本的sdl? – user1810087
@itwasntpete我們正在使用1.2.15。在您的建議後,我嘗試將32更改爲24,並查看所有可用選項。唯一的工作是SDL_FULLSCREEN,所有其他也導致了分段錯誤。你有洞察力爲什麼?如果沒有,我會用我得到的,但會很有趣,否則以及:) – pingul
你試過[SDL_GetVideoInfo()](http://www.libsdl.org/release/SDL-1.2。 15/docs/html/sdlvideoinfo.html)看看「可能」最好?另外,請發佈一些錯誤。 – user1810087