首页 \ 问答 \ Proguard吃了我的Object.wait()(Proguard ate my Object.wait())

Proguard吃了我的Object.wait()(Proguard ate my Object.wait())

我刚刚发现ProGuard删除了一个.wait()调用,我用来同步线程,导致竞争条件导致一天的调试快乐:)无论如何......

我将其跟踪到以下部分的proguard配置:

-assumenosideeffects public class android.util.Log {
    <methods>;
}

我想知道为什么会这样。 我不确定为什么假设删除Log类没有副作用导致在不同的类/对象上删除.wait()。

我看到ProGuard优化也删除了#wait()调用 ,其中Eric解释说可能会发生这样的事情。 但是,他没有解释原因。

另外,我在这里找到了如何删除Logs的示例( http://proguard.sourceforge.net/index.html#manual/examples.html )。 所以,我可以替换这个配置程序(但这不是这个问题的重点)。


I just found that ProGuard removed a .wait() call which I used to synchronize threads, which lead to a race condition which lead to a day of happy debugging :) Anyway...

I tracked it down to following piece of proguard configuration:

-assumenosideeffects public class android.util.Log {
    <methods>;
}

I want to understand WHY this happened. I am not sure why assuming that removal of Log class has no side effects leads to removal of .wait() on different class/object.

I saw ProGuard optimization also remove #wait() calls where Eric explains that such things may happen. However, he doesn't explain why.

Also, I found example how to remove Logs here (http://proguard.sourceforge.net/index.html#manual/examples.html). So, I can replace this piece of proguard of configuration (but it's not the point of this question).


原文:https://stackoverflow.com/questions/16846691
更新时间:2023-09-27 06:09

最满意答案

不需要三个单独的mmap 。 只需mmap一次,然后计算每个平面相对于整个地图的基本指针的基指针。

编辑:你需要这样的东西:

unsigned char *y = mmap(...); /* map total size of all 3 planes */
unsigned char *u = y + y_height*y_bytes_per_line;
unsigned char *v = u + u_height*u_bytes_per_line;

There is no need for three separate mmaps. Simply mmap once, then compute the base pointer for each plane relative to the base pointer of the whole map.

Edit: You need something like this:

unsigned char *y = mmap(...); /* map total size of all 3 planes */
unsigned char *u = y + y_height*y_bytes_per_line;
unsigned char *v = u + u_height*u_bytes_per_line;

相关问答

更多
  • 来自IEEE 1003.1: mmap()函数应建立进程的地址空间和文件,共享内存对象或[TYM]类型的内存对象之间的映射。 它需要所有的虚拟地址空间,因为这正是mmap() 所做的 。 事实上它并没有真正耗尽内存并不重要 - 你无法映射更多的地址空间。 既然你把结果和访问权当成内存,那么你建议如何访问超过2 ^ 32个字节的文件? 即使mmap()没有失败,您仍然可以在32位地址空间中空出之前读取第一个4GB。 当然,您可以将mmap()一个滑动的32位窗口放在文件上,但这并不一定能净化您的任何好处,除非 ...
  • 您的问题的简单答案“我是否需要为每个套接字创建和分配线程?” 没有”。 线程是射击自己的完美方式。 但请看这一部分: “[...]只要在定义的文件描述符上发生事件,就会调用其事件处理函数[...]” 。 现在回答问题: 谁将调用事件处理程序? 你的程序如何注意到事件发生了? 当然,您可以为每个描述符创建每个线程,并使用例如阻塞读取功能“坐”它们。 然后死于试图与你的主线程同步的可怕死亡。 但更好的解决方案是使一个主循环步骤检查事件 (例如使用select或poll函数),然后,对于每个“活动”的描述符从主循 ...
  • 有一点是肯定的:结果取决于系统的状态,而不仅仅取决于正在运行的应用程序。 在我的机器上,我运行程序的前两次RES增加了136 kB,但后续运行根本没有任何增加 - 可能是OS已经将整个文件放在缓存中。 有趣的是,这些价值观在运行之间存在显着差异。 在第一次运行中,RES的跳转从344到480 kB,但后者运行的RES值始终为348 kB。 SHR也有类似的变化:第一次跳跃为136 kB,之后没有变化。 我可以通过覆盖文件来强制原始情况(使用136 kB跳转),该文件随后在运行应用程序之前使用dd用零映射。 ...
  • 好的,在写完大部分问题之后,我发现这个不同的问题与我的搜索方式有所不同: 在调用mmap之后我是否需要保持文件打开? 答案引用了POSIX手册,结果在man页面中(在munmap下,传递: - |),解释说关闭描述符不会自动取消映射映射。 所以看起来我们需要修改我们的驱动程序关闭代码以使相关的内存映射无效,以便在用户空间中发生段错误。 我决定发布问题以防其他人搜索类似的事情。 Ok, after writing most of the question I found this different ques ...
  • 几个问题: 避免混合高级I / O(fopen(),fseek())和一些低级操作(如mmap())。 尽管可以使用fileno()获取低级别文件描述符,这就像是使用最长的路径到达同一个地方。 另外,仅仅使用mmap()可以打破BSD和POSIX以外的兼容性,所以通过使用标准的CI / O函数你什么也得不到。 直接使用open()和lseek()。 在内存映射的同一文件上使用流格式的I / O(fprintf())是没有意义的。 当你记忆一个文件时,你隐式地告诉系统你要用它作为随机访问(直接索引)数据。 f ...
  • 我相信你是对的,有时文件描述符可能已经在使用中。 我从http://tldp.org/LDP/abs/html/io-redirection.html#FTN.AEN17716得到了这个 “使用文件描述符5可能会导致问题。当Bash创建子进程时,与exec一样,子进程继承fd 5(请参阅Chet Ramey的归档电子邮件, SUBJECT:RE:文件描述符5保持打开状态 )。独自一人。“ 对此的解决方案在bash手册的第3.6节第2节中有详细说明。 可以在文件描述符号之前的每个重定向可以改为在{varnam ...
  • 在您的客户端中,您将无限次重新发送内容,因此请删除外部while循环。 它可能只是: with open('mytext.txt', 'rb') as f: l = f.read(1024) while l: s.send(l) print 'Sent ', repr(l) l = f.read(1024) 您的服务器也有问题,可能是错误的原因,因为它在读取输入数据时崩溃。 您正在打开文件描述符,然后在循环之前关闭它,因为您正在使用上下文管理 ...
  • 这是一个想法的骨架: #!/bin/bash exec 5< <(sleep 4; pwd) while true do if read -t 0 -u 5 dummy then echo Data available cat <&5 break else echo No data fi sleep 1 done 从Bash参考手册: 如果timeout为0,则read立即返回,而不尝试读取和数据。 如果输入在指定的文件描述符上可用,则退出状态为 ...
  • 从阅读CPython 2.7源代码来看,似乎在Windows上,指定fileno = 0与指定fileno = -1具有相同的效果,其中后者意味着“映射匿名内存”。 在Unix上只接受-1 :在我的带有Python 2.6.5的64位Ubuntu盒子上, mmap.mmap(0, 256)失败, errno=19 (No such device)和mmap.mmap(-1, 256)工作精细。 底线: fileno = 0是fileno = -1的非可移植Windows版变体。 它可能会被弃用(甚至在代码中 ...
  • 不需要三个单独的mmap 。 只需mmap一次,然后计算每个平面相对于整个地图的基本指针的基指针。 编辑:你需要这样的东西: unsigned char *y = mmap(...); /* map total size of all 3 planes */ unsigned char *u = y + y_height*y_bytes_per_line; unsigned char *v = u + u_height*u_bytes_per_line; There is no need for thre ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。