我无法确定这里出了什么问题。
我是一个团队的一员,我们正在使用 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 Mavericks 上运行,并使用终端编译
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( native ) 父进程:zsh [297] 负责人:航站楼 [155] 用户编号: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
我希望这是相关的信息。请告诉我我是否也在格式化这个奇怪的东西。
最佳答案
固定每像素位数并不是一个好主意。也不是每个 Mac-OS 都支持 32 位的 SDL。尝试一些其他值。 0 用于自动分配,通常不在 Mac 上运行。我认为 24 应该可以。
screen = SDL_SetVideoMode(640, 480, 24, SDL_SWSURFACE);
您还可以使用 SDL_GetVideoInfo(); 来确定您应该使用哪种模式。
关于c++ - 调用 SDL_SetVideoMode 时出现段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20456642/
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee
我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie