.NET Core 中如何调试 死锁 ?

这篇文章,我们研究一下如何调试一个 死锁问题,可以下载一下 https://github.com/dotnet/samples/tree/main/core/diagnostics/DiagnosticScenarios 源码,程序运行后,你会发现api无响应而且线程会不断增长,然后你会学习到用不同的工具去分析这个死锁问题。

生成 core dump

为了能找出程序无响应的原因,core dump 提供了当时线程的状态以及各种存在线程竞争的锁,接下来运行如下命令:

dotnet run

为了能找到 进程ID,使用如下命令。

dotnet-trace ps

可以自己查看一下 shell 输出,我们的进程是 4807,你的进程号可能不一样,接下来访问URL: https://localhost:5001/api/diagscenario/deadlock ,你会发现这个api请求会一直得不到response,等 10-15s 后,使用下面的命令收集一个 dump 文件。

dotnet-dump collect -p 4807

分析 core dump

为了能够对生成好的 dump 进行分析,使用如下命令 dotnet-dump analyze 命令,参考如下:

dotnet-dump analyze  ~/.dotnet/tools/core_20190513_143916

因为是一个莫名的无响应问题,所以你可能想先对进程中的所有线程有一个整体的感知。

> threads
*0 0x1DBFF (121855)1 0x1DC01 (121857)2 0x1DC02 (121858)3 0x1DC03 (121859)4 0x1DC04 (121860)5 0x1DC05 (121861)6 0x1DC06 (121862)7 0x1DC07 (121863)8 0x1DC08 (121864)9 0x1DC09 (121865)10 0x1DC0A (121866)11 0x1DC0D (121869)12 0x1DC0E (121870)13 0x1DC10 (121872)14 0x1DC11 (121873)15 0x1DC12 (121874)16 0x1DC13 (121875)17 0x1DC14 (121876)18 0x1DC15 (121877)19 0x1DC1C (121884)20 0x1DC1D (121885)21 0x1DC1E (121886)22 0x1DC21 (121889)23 0x1DC22 (121890)24 0x1DC23 (121891)25 0x1DC24 (121892)26 0x1DC25 (121893)
...
...317 0x1DD48 (122184)318 0x1DD49 (122185)319 0x1DD4A (122186)320 0x1DD4B (122187)321 0x1DD4C (122188)

输出中展示了进程中的所有线程ID,以及相关的 调试器线程ID操作系统线程ID

接下来我们有必要了解下每个线程都在做什么?可以用 clrstack 查看线程栈,为了能查看所有的线程栈,使用如下命令:

clrstack -all.........Child SP               IP Call Site
00007F2AE37B5680 00007f305abc6360 [GCFrame: 00007f2ae37b5680]
00007F2AE37B5770 00007f305abc6360 [GCFrame: 00007f2ae37b5770]
00007F2AE37B57D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2ae37b57d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2AE37B5920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2AE37B5950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2AE37B5CA0 00007f30593044af [GCFrame: 00007f2ae37b5ca0]
00007F2AE37B5D70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2ae37b5d70]
OS Thread Id: 0x1dc82Child SP               IP Call Site
00007F2AE2FB4680 00007f305abc6360 [GCFrame: 00007f2ae2fb4680]
00007F2AE2FB4770 00007f305abc6360 [GCFrame: 00007f2ae2fb4770]
00007F2AE2FB47D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2ae2fb47d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2AE2FB4920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2AE2FB4950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2AE2FB4CA0 00007f30593044af [GCFrame: 00007f2ae2fb4ca0]
00007F2AE2FB4D70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2ae2fb4d70]
OS Thread Id: 0x1dc83Child SP               IP Call Site
00007F2AE27B3680 00007f305abc6360 [GCFrame: 00007f2ae27b3680]
00007F2AE27B3770 00007f305abc6360 [GCFrame: 00007f2ae27b3770]
00007F2AE27B37D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2ae27b37d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2AE27B3920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2AE27B3950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2AE27B3CA0 00007f30593044af [GCFrame: 00007f2ae27b3ca0]
00007F2AE27B3D70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2ae27b3d70]
OS Thread Id: 0x1dc84Child SP               IP Call Site
00007F2AE1FB2680 00007f305abc6360 [GCFrame: 00007f2ae1fb2680]
00007F2AE1FB2770 00007f305abc6360 [GCFrame: 00007f2ae1fb2770]
00007F2AE1FB27D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2ae1fb27d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2AE1FB2920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2AE1FB2950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2AE1FB2CA0 00007f30593044af [GCFrame: 00007f2ae1fb2ca0]
00007F2AE1FB2D70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2ae1fb2d70]
OS Thread Id: 0x1dc85Child SP               IP Call Site
00007F2AE17B1680 00007f305abc6360 [GCFrame: 00007f2ae17b1680]
00007F2AE17B1770 00007f305abc6360 [GCFrame: 00007f2ae17b1770]
00007F2AE17B17D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2ae17b17d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2AE17B1920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2AE17B1950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2AE17B1CA0 00007f30593044af [GCFrame: 00007f2ae17b1ca0]
00007F2AE17B1D70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2ae17b1d70]
OS Thread Id: 0x1dc86Child SP               IP Call Site
00007F2AE0FB0680 00007f305abc6360 [GCFrame: 00007f2ae0fb0680]
00007F2AE0FB0770 00007f305abc6360 [GCFrame: 00007f2ae0fb0770]
00007F2AE0FB07D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2ae0fb07d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2AE0FB0920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2AE0FB0950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2AE0FB0CA0 00007f30593044af [GCFrame: 00007f2ae0fb0ca0]
00007F2AE0FB0D70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2ae0fb0d70]
OS Thread Id: 0x1dc87Child SP               IP Call Site
00007F2AE07AF680 00007f305abc6360 [GCFrame: 00007f2ae07af680]
00007F2AE07AF770 00007f305abc6360 [GCFrame: 00007f2ae07af770]
00007F2AE07AF7D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2ae07af7d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2AE07AF920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2AE07AF950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2AE07AFCA0 00007f30593044af [GCFrame: 00007f2ae07afca0]
00007F2AE07AFD70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2ae07afd70]
OS Thread Id: 0x1dc88Child SP               IP Call Site
00007F2ADFFAE680 00007f305abc6360 [GCFrame: 00007f2adffae680]
00007F2ADFFAE770 00007f305abc6360 [GCFrame: 00007f2adffae770]
00007F2ADFFAE7D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2adffae7d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2ADFFAE920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2ADFFAE950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2ADFFAECA0 00007f30593044af [GCFrame: 00007f2adffaeca0]
00007F2ADFFAED70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2adffaed70]
...
...
Observing the callstacks for all 300+ threads shows a pattern where a majority of the threads share a common callstack:ConsoleCopy
OS Thread Id: 0x1dc88Child SP               IP Call Site
00007F2ADFFAE680 00007f305abc6360 [GCFrame: 00007f2adffae680]
00007F2ADFFAE770 00007f305abc6360 [GCFrame: 00007f2adffae770]
00007F2ADFFAE7D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2adffae7d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2ADFFAE920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2ADFFAE950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2ADFFAECA0 00007f30593044af [GCFrame: 00007f2adffaeca0]
00007F2ADFFAED70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2adffaed70]

观察这超300+ 的线程栈,发现很多线程都是类似下面的线程栈。

OS Thread Id: 0x1dc88Child SP               IP Call Site
00007F2ADFFAE680 00007f305abc6360 [GCFrame: 00007f2adffae680]
00007F2ADFFAE770 00007f305abc6360 [GCFrame: 00007f2adffae770]
00007F2ADFFAE7D0 00007f305abc6360 [HelperMethodFrame_1OBJ: 00007f2adffae7d0] System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
00007F2ADFFAE920 00007F2FE392B31F testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_1() [/home/marioh/webapi/Controllers/diagscenario.cs @ 36]
00007F2ADFFAE950 00007F2FE392B46D System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/__w/3/s/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
00007F2ADFFAECA0 00007f30593044af [GCFrame: 00007f2adffaeca0]
00007F2ADFFAED70 00007f30593044af [DebuggerU2MCatchHandlerFrame: 00007f2adffaed70]

从调用栈看,api请求已经进去了 deadlock 方法,然后在 Monitor.ReliableEnter 处卡住,这就说明有其他线程已经进去了这个临界区

接下来我们要寻找到底是哪一个线程正在持有锁?可以用 syncblk 来获取更多线程锁信息。

> syncblk
Index         SyncBlock MonitorHeld Recursion Owning Thread Info          SyncBlock Owner43 00000246E51268B8          603         1 0000024B713F4E30 5634  28   00000249654b14c0 System.Object44 00000246E5126908            3         1 0000024B713F47E0 51d4  29   00000249654b14d8 System.Object
-----------------------------
Total           344
CCW             1
RCW             2
ComClassFactory 0
Free            0

这里有两个列需要注意下:

  1. MonitorHeld

它记录了这个持有锁当前有多少 持有线程等待线程

  1. Owning Thread Info

它表示当前持有锁的线程信息。

到这里,我们看到有两个线程 0x56340x51d4 持有了一个锁,接下来可以切到各自线程看看里面到底做了什么?可以用 setthreadclrstack 命令。

首先看一下第一个线程 0x5634,我们发现它正在获取一个锁,但通过 syncblk 我们知道这个线程已经持有了一个锁,这问题就大了,可以想象所有等待这个持有锁的线程将会被无限期等待。

> setthread 28
> clrstack
OS Thread Id: 0x5634 (28)Child SP               IP Call Site
0000004E46AFEAA8 00007fff43a5cbc4 [GCFrame: 0000004e46afeaa8]
0000004E46AFEC18 00007fff43a5cbc4 [GCFrame: 0000004e46afec18]
0000004E46AFEC68 00007fff43a5cbc4 [HelperMethodFrame_1OBJ: 0000004e46afec68] System.Threading.Monitor.Enter(System.Object)
0000004E46AFEDC0 00007FFE5EAF9C80 testwebapi.Controllers.DiagScenarioController.DeadlockFunc() [C:\Users\dapine\Downloads\Diagnostic_scenarios_sample_debug_target\Controllers\DiagnosticScenarios.cs @ 58]
0000004E46AFEE30 00007FFE5EAF9B8C testwebapi.Controllers.DiagScenarioController.<deadlock>b__3_0() [C:\Users\dapine\Downloads\Diagnostic_scenarios_sample_debug_target\Controllers\DiagnosticScenarios.cs @ 26]
0000004E46AFEE80 00007FFEBB251A5B System.Threading.ThreadHelper.ThreadStart_Context(System.Object) [/_/src/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs @ 44]
0000004E46AFEEB0 00007FFE5EAEEEEC System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/_/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @ 201]
0000004E46AFEF20 00007FFEBB234EAB System.Threading.ThreadHelper.ThreadStart() [/_/src/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs @ 93]
0000004E46AFF138 00007ffebdcc6b63 [GCFrame: 0000004e46aff138]
0000004E46AFF3A0 00007ffebdcc6b63 [DebuggerU2MCatchHandlerFrame: 0000004e46aff3a0]

第二个线程情况类似,剩下的 300+ 线程也差不多都是在这些 死锁 的 lock 上无限期的等待。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/296775.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ProSolid下的遍历访问封装代码

在ProE二次开发中&#xff0c;时常需要遍历ProSolid下的面、点、轴等几何元素。我们知道&#xff0c;ProToolkit下的遍历函数还是有点小麻烦的&#xff0c;而ProWebLink中就简单很多&#xff0c;比如要遍历某ProSolid下的所有Group&#xff0c;代码如下&#xff1a; 1 var gro…

mybatis 多租户saas_MybatisPlus 多租户架构(SaaS)实现

1. 引言读写分离要做的事情就是对于一条SQL该选择哪个数据库去执行&#xff0c;至于谁来做选择数据库这件事儿&#xff0c;无非两个&#xff0c;要么中间件帮我们做&#xff0c;要么程序自己做。因此&#xff0c;一般来讲&#xff0c;读写分离有两种实现方式。第一种是依靠中间…

Floodlight 在 ChannelPipeline 图

我们知道&#xff0c;在Netty架构&#xff0c;一个ServerBootstrap用于生成server端的Channel的时候都须要提供一个ChannelPipelineFactory类型的參数&#xff0c;用于服务于建立连接的Channel&#xff0c;流水线处理来自某个client的请求。所以这里的 OpenflowPipelineFactory…

html超文本链接本页面,从HTML语言到网上家园 第三章 超文本链接(1)-网页设计,HTML/CSS...

超文本链接是 html 语言最大的特点之一&#xff0c;使用超文本链接可以极大的增加文件访问的灵活度&#xff0c;人们可以通过点击页面中的链接指针查看所需的内容&#xff0c;进退自如&#xff0c;灵活方便&#xff0c;这更加符合人的跳跃、交叉的思维方式。凡是浏览过网页的人…

PS景观彩色平面图技巧

1、关于水系&#xff0c;园林学习网 PS景观彩色平面图 水要有阴影&#xff0c;不过是内投影。可以用图层特效来做&#xff0c;也可以用高斯模糊。 要有光感&#xff0c;可以用退晕&#xff0c;也可以用滤镜打光。 2、草地 草地在红线内外一定要区分开色象和明度饱和度&#xff…

牛顿如果穿越到现在,能看懂相对论和量子力学吗?

全世界只有3.14 % 的人关注了爆炸吧知识今天要讲给大家讲一个从朋友BOSS那里听来的故事&#xff0c;而故事的主人公就是赫赫有名的牛顿大神。话说那一天&#xff0c;BOSS在牛顿的苹果树下思考人生。突然牛顿就从苹果树下的棺材里爬了出来&#xff0c;棺材板怎么压都压不住。于是…

【啊哈!算法】之二、插入排序

作者&#xff1a;jofranks 原创作品&#xff0c;转载请标明出处&#xff01;版权所有&#xff0c;侵权必究! 来源&#xff1a;http://blog.csdn.net/jofranks 插入排序包括&#xff1a;直接插入排序&#xff0c;折半插入排序&#xff0c;希尔排序~&#xff01; OK&#xff0c;下…

02Prism WPF 入门实战 - 建项

1.概要Prism介绍Github: https://github.com/PrismLibrary/Prism开发文档&#xff1a;https://prismlibrary.com/docs/Prism是一个框架&#xff0c;用于在WPF、Xamarin Forms、Uno Platform和WinUI中构建松散耦合、可维护和可测试的XAML应用程序。设计目标 为了实现下列目的&a…

rowspan 动态变化_使用colspan和rowspan动态删除html表中的多个列

好的&#xff0c;您的代码中的一个问题是&#xff0c;您删除了当前正在使用for进行迭代的单元格。我改变了你的第一个循环来完成所有反向&#xff1a;for (var i (rows[0].cells.length -1); i > 0; i--)&#xff0c;从后到前...所以没有索引在删除时发生变化。第二个问题是…

[转]Linux中如何自动启动服务

linux自动启动服务很简单&#xff0c;最简单的是把启动命令放到/etc/rc.d/rc.local文件里。这样就可以每次启动的时候自动启动服务了。例如对于 apache&#xff0c;编译好apache后会在安装目录的bin下生成apachectl文件&#xff0c;这是个启动脚本&#xff0c;我们只需要把这个…

一个C实现的线程池(产品暂未运用)

https://github.com/Pithikos/C-Thread-Pool

html首页 slider图片切换效果,jQuery插件Slider Revolution实现响应动画滑动图片切换效果...

jQuery插件Slider Revolution实现响应动画滑动图片切换效果2018-12-31编程之家https://www.jb51.cc这是一款非常强大的内容切换插件&#xff0c;它基于jQuery&#xff0c;它充分响应&#xff0c;支持移动设备&#xff0c;支持手机触摸&#xff0c;键盘翻页&#xff1b;它内置幻…

Asp.Net+Jquery.Ajax详解5-$.getScript

目录&#xff08;已经更新的文章会有连接&#xff0c;从7月25日开始&#xff0c;每2到3天更新一篇&#xff09;&#xff1a; Asp.NetJquery.Ajax详解1-开篇&#xff08;2012.07.25发&#xff09; Asp.NetJquery.Ajax详解2-$.Load&#xff08;2012.07.26发&#xff09; Asp.NetJ…

大数据告诉你:学历真的能改变命运!!

全世界只有3.14 % 的人关注了爆炸吧知识央视新闻曾做过关于高考的调查&#xff0c;结果有七成网友支持高考取消数学&#xff0c;看到新闻后&#xff0c;有一位网友却一针见血地评论道&#xff1a;数学考试存在的意义就是把这七成网友筛选掉。的确&#xff0c;虽然买菜不需要专业…

.net core 中如何有效屏蔽重复提交

咨询区 Guilherme Ferreira&#xff1a;我通过 post 方式向我的一个webapi中提交数据&#xff0c;然后插入到数据库中&#xff0c;在 ui端&#xff0c;当用户点击某一个 button 之后&#xff0c;代码会将 button 禁用&#xff0c;但因为某些原因&#xff0c;点击按钮的速度比禁…

小米8ios图标包下载_小米互传PC端抢先下载,免流量、高速互传,支持多设备共享...

小米早在MIUI初期就已经在开始探索手机与电脑之间互传文件的问题&#xff0c;MIUI"无线数据线"功能一直备受喜欢。手机与电脑之间互传&#xff0c;90%的用户都选择使用WX或者QQ来实现&#xff0c;它们互传的通道是互联网&#xff0c;无网时不可使用。为解决这个问题&…

sql server2008中怎样用sql语句创建数据库和数据表

这是简单用代码实现创建数据库和数据表的sql语句&#xff0c;如下&#xff1a; --调用系统数据库-- use master go /***防止你要创建的数据库同名&#xff0c;先把它删除掉****/ if Exists(select * from dbo.sysdatabases where nameTestDB) begin drop database TestDB end g…

[C++][IO]读写二进制文件

1. 以二进制方式读写结构体 struct Student {string name;string sex;int age; }void write(string filePath, const struct Student* stu, int n) {FILE *fp;int i;if((fpfopen(filePath,"wb"))NULL){printf("cant open the file");return;}for(i0;i<n…

HTML怎么做类似QQ聊天气泡,h5实现QQ聊天气泡的实例介绍

这篇文章主要介绍了HTML5实现QQ聊天气泡效果&#xff0c;用 HTML/CSS 做了个类似QQ的聊天气泡&#xff0c;具有一定的参考价值&#xff0c;感兴趣的小伙伴们可以参考一下今天自己用 HTML/CSS 做了个类似QQ的聊天气泡&#xff0c;以下是效果图&#xff1a;以下说下关键地方的样式…

高等数学的用处之一

1 只能说计算的真精准2 龙虾&#xff1a;我都准备半天了&#xff0c;你俩到底上不上&#xff1f;3 猫(≧^.^≦)&#xff1a;我为这个宿舍付出太多了&#xff01;4 请举一个日常生活中利用高等数学来解决问题的案例。5 男生做什么会让女生不开心7 人家拍的泸沽湖的水性杨花和我拍…