Proxmark3 community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

Announcement

Time changes and with it the technology
Proxmark3 @ discord

Users of this forum, please be aware that information stored on this site is not private.

#1 2013-06-04 20:59:00

piwi
Contributor
Registered: 2013-06-04
Posts: 704

PATCH: Client hangs when previous USB-Command is not yet transferred

Hangs in several commands (e.g. "hf mf chk" or "hf mf nested" with option "t") are caused by a compiler optimization.

Reason: in proxmark.c there is an empty while loop

  while(txcmd_pending);

which should wait until a previos (pending) USB-Command is transmitted to the proxmark. The parallel threat responsible for the USB-communication would then set txcmd_pending to false and the while loop would be ended.

Unfortunately the compiler doesn't know about parallel threats and therefore optimizes the loop to nothing for txcmd_pending==false and an infinite loop for txcmd_pending==true. The latter then results in the observed hangs.

Simply declaring txcmd_pending as volatile prevents the compiler from optimizing the loop and fixes this issue:

Index: C:/proxmark3/client/proxmark3.c
===================================================================
--- C:/proxmark3/client/proxmark3.c	(revision 730)
+++ C:/proxmark3/client/proxmark3.c	(working copy)
@@ -26,7 +26,7 @@
 
 static serial_port sp;
 static UsbCommand txcmd;
-static bool txcmd_pending = false;
+volatile static bool txcmd_pending = false;
 
 void SendCommand(UsbCommand *c) {
 #if 0

This probably fixes the shitty roll issue https://code.google.com/p/proxmark3/issues/detail?id=45 as well.

Can one of the committers please check and commit.

(tested on SVN 730, Windows 8 x64, mingw)

Offline

#2 2013-06-05 09:50:27

holiman
Contributor
Registered: 2013-05-03
Posts: 566

Re: PATCH: Client hangs when previous USB-Command is not yet transferred

Thanks! Committed as r731

Offline

Board footer

Powered by FluxBB