当我在调试模式下运行时,应用程序崩溃了,但当我正常运行时,它可以工作。 我认为问题发生在附加调试器时。

Log:

A/art: art/runtime/jdwp/jdwp_event.cc:661] Check failed: Thread::Current() != GetDebugThread() (Thread::Current()=0x7f44a18400, GetDebugThread()=0x7f44a18400) Expected event thread
A/art: art/runtime/runtime.cc:422] Runtime aborting...
A/art: art/runtime/runtime.cc:422] Aborting thread:
A/art: art/runtime/runtime.cc:422] "JDWP" prio=5 tid=4 WaitingForDebuggerSend
A/art: art/runtime/runtime.cc:422]   | group="" sCount=0 dsCount=0 obj=0x12c60280 self=0x7f44a18400
A/art: art/runtime/runtime.cc:422]   | sysTid=24137 nice=0 cgrp=default sched=0/0 handle=0x7f4b904450
A/art: art/runtime/runtime.cc:422]   | state=R schedstat=( 132066712 16401043 106 ) utm=9 stm=2 core=3 HZ=100
A/art: art/runtime/runtime.cc:422]   | stack=0x7f4b80a000-0x7f4b80c000 stackSize=1005KB
A/art: art/runtime/runtime.cc:422]   | held mutexes= "abort lock"
A/art: art/runtime/runtime.cc:422]   native: #00 pc 000000000047e2cc  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
A/art: art/runtime/runtime.cc:422]   native: #01 pc 000000000047e2c8  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
A/art: art/runtime/runtime.cc:422]   native: #02 pc 0000000000452434  /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+480)
A/art: art/runtime/runtime.cc:422]   native: #03 pc 00000000004403ac  /system/lib64/libart.so (_ZNK3art10AbortState10DumpThreadERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEPNS_6ThreadE+56)
A/art: art/runtime/runtime.cc:422]   native: #04 pc 0000000000440228  /system/lib64/libart.so (_ZNK3art10AbortState4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+668)
A/art: art/runtime/runtime.cc:422]   native: #05 pc 0000000000433bfc  /system/lib64/libart.so (_ZN3art7Runtime5AbortEPKc+148)
A/art: art/runtime/runtime.cc:422]   native: #06 pc 00000000000e597c  /system/lib64/libart.so (_ZN3art10LogMessageD2Ev+1592)
A/art: art/runtime/runtime.cc:422]   native: #07 pc 00000000002f8458  /system/lib64/libart.so (_ZN3art4JDWP9JdwpState24AcquireJdwpTokenForEventEm+624)
A/art: art/runtime/runtime.cc:422]   native: #08 pc 00000000002f7b1c  /system/lib64/libart.so (_ZN3art4JDWP9JdwpState29SendRequestAndPossiblySuspendEPNS0_9ExpandBufENS0_17JdwpSuspendPolicyEm+248)
A/art: art/runtime/runtime.cc:422]   native: #09 pc 00000000002fcb08  /system/lib64/libart.so (_ZN3art4JDWP9JdwpState16PostClassPrepareEPNS_6mirror5ClassE+1380)
A/art: art/runtime/runtime.cc:422]   native: #10 pc 0000000000124a9c  /system/lib64/libart.so (_ZN3art11ClassLinker11DefineClassEPNS_6ThreadEPKcmNS_6HandleINS_6mirror11ClassLoaderEEERKNS_7DexFileERKNS9_8ClassDefE+804)
A/art: art/runtime/runtime.cc:422]   native: #11 pc 0000000000381d04  /system/lib64/libart.so (_ZN3artL25DexFile_defineClassNativeEP7_JNIEnvP7_jclassP8_jstringP8_jobjectS7_S7_+344)
A/art: art/runtime/runtime.cc:422]   native: #12 pc 00000000001dd40c  /system/framework/arm64/boot-core-libart.oat (???)
A/art: art/runtime/runtime.cc:422]   at dalvik.system.DexFile.defineClassNative(Native method)
A/art: art/runtime/runtime.cc:422]   at dalvik.system.DexFile.defineClass(DexFile.java:296)
A/art: art/runtime/runtime.cc:422]   at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:289)
A/art: art/runtime/runtime.cc:422]   at dalvik.system.DexPathList.findClass(DexPathList.java:418)
A/art: art/runtime/runtime.cc:422]   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
A/art: art/runtime/runtime.cc:422]   at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
A/art: art/runtime/runtime.cc:422]   at com.android.tools.fd.runtime.IncrementalClassLoader.findClass(IncrementalClassLoader.java:62)
A/art: art/runtime/runtime.cc:422]   at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
A/art: art/runtime/runtime.cc:422]   at java.lang.ClassLoader.loadClass(ClassLoader.java:367)
A/art: art/runtime/runtime.cc:422]   at java.lang.ClassLoader.loadClass(ClassLoader.java:367)
A/art: art/runtime/runtime.cc:422]   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
A/art: art/runtime/runtime.cc:422] Dumping all threads without appropriate locks held: thread list lock mutator lock

我有Windows 7上的OpenSSL x64,我从谷歌代码上的OpenSSL -for- Windows下载的。我试着跑:

openssl pkcs12 -export -in "path.p12" -out "newfile.pem" 

但是我得到了一个错误。

unable to load private key

如何使用OpenSSL从pkcs# 12存储中提取PEM格式的证书?

我使用Python 2从ASCII编码的文本文件解析JSON。

当用json或simplejson加载这些文件时,我的所有字符串值都转换为Unicode对象而不是字符串对象。问题是,我必须将数据与一些只接受字符串对象的库一起使用。我不能更改库也不能更新它们。

是否有可能获得字符串对象而不是Unicode对象?

例子

>>> import json
>>> original_list = ['a', 'b']
>>> json_list = json.dumps(original_list)
>>> json_list
'["a", "b"]'
>>> new_list = json.loads(json_list)
>>> new_list
[u'a', u'b']  # I want these to be of type `str`, not `unicode`

(2017年一个简单而干净的解决方案是使用最新版本的Python——即Python 3和更高版本。)

我最近无意中发现了这段代码:

function xrange($min, $max) 
{
    for ($i = $min; $i <= $max; $i++) {
        yield $i;
    }
}

我以前从未见过这个yield关键字。试着运行我得到的代码

解析错误:语法错误,意外的T_VARIABLE在x行

那么yield关键字是什么呢?它是有效的PHP吗?如果是,我该怎么用呢?

在我的生产错误日志中,我偶尔会看到:

SQLSTATE[HY000]:一般错误:1205 超过锁等待超时;试一试 重新启动事务

我知道哪个查询在那个时刻试图访问数据库,但是是否有一种方法可以找出哪个查询在那个精确的时刻拥有锁?

我知道我可以单独发出一个alter表,将表存储从MyISAM更改为InnoDB。

我想知道是否有一种方法可以快速将它们全部更改为InnoDB?

如何使用Assert。抛出以断言异常的类型和实际的消息措辞?

就像这样:

Assert.Throws<Exception>(
    ()=>user.MakeUserActive()).WithMessage("Actual exception message")

我正在测试的方法抛出了多个具有不同消息的相同类型的消息,我需要一种方法来测试是否根据上下文抛出了正确的消息。

我正在查看这里的strlen代码,我想知道在代码中使用的优化是否真的需要?例如,为什么像下面这样的工作不一样好或更好?

unsigned long strlen(char s[]) {
    unsigned long i;
    for (i = 0; s[i] != '\0'; i++)
        continue;
    return i;
}

更简单的代码是不是更好和/或更容易编译器优化?

strlen在链接后面的页面上的代码是这样的:

/* Copyright (C) 1991, 1993, 1997, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se); commentary by Jim Blandy (jimb@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <string.h> #include <stdlib.h> #undef strlen /* Return the length of the null-terminated string STR. Scan for the null terminator quickly by testing four bytes at a time. */ size_t strlen (str) const char *str; { const char *char_ptr; const unsigned long int *longword_ptr; unsigned long int longword, magic_bits, himagic, lomagic; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = str; ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; ++char_ptr) if (*char_ptr == '\0') return char_ptr - str; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to 8-byte longwords. */ longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ magic_bits = 0x7efefeffL; himagic = 0x80808080L; lomagic = 0x01010101L; if (sizeof (longword) > 4) { /* 64-bit version of the magic. */ /* Do the shift in two steps to avoid a warning if long has 32 bits. */ magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; himagic = ((himagic << 16) << 16) | himagic; lomagic = ((lomagic << 16) << 16) | lomagic; } if (sizeof (longword) > 8) abort (); /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ for (;;) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. */ longword = *longword_ptr++; if ( #if 0 /* Add MAGIC_BITS to LONGWORD. */ (((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) #else ((longword - lomagic) & himagic) #endif != 0) { /* Which of the bytes was the zero? If none of them were, it was a misfire; continue the search. */ const char *cp = (const char *) (longword_ptr - 1); if (cp[0] == 0) return cp - str; if (cp[1] == 0) return cp - str + 1; if (cp[2] == 0) return cp - str + 2; if (cp[3] == 0) return cp - str + 3; if (sizeof (longword) > 4) { if (cp[4] == 0) return cp - str + 4; if (cp[5] == 0) return cp - str + 5; if (cp[6] == 0) return cp - str + 6; if (cp[7] == 0) return cp - str + 7; } } } } libc_hidden_builtin_def (strlen)

为什么这个版本运行得很快?

它是不是做了很多不必要的工作?

我得到了错误

gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED:缺少或权限不足。

对于下面关于else语句的代码

db.collection("users")
    .get()
    .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
        @Override
        public void onComplete(@NonNull Task<QuerySnapshot> task) {
             if (task.isSuccessful()) {
                 for (DocumentSnapshot document : task.getResult()) {
                     s(document.getId() + " => " + document.getData());
                 }
             } else {
                 s("Error getting documents."+ task.getException());
             }
         }
     });

我正在调试一些JavaScript,无法解释这个||做什么:

function (title, msg) {
  var title = title || 'Error';
  var msg   = msg || 'Error on Request';
}

为什么这个家伙使用var title = title || 'ERROR'?我有时也看到它没有var声明。