Re: [Quickfix-developers] NewOrderList addgroup threw "Attempted to read or write protected memory.
Brought to you by:
orenmnero
From: Djalma R. d. S. F. <drs...@gm...> - 2009-01-24 00:56:52
|
This error occurs because the .NET runtime sometimes moves the objects in memory to compact the GC Heap, this cheats the unmanaged code and leads to an access violation. The solution is pinning the objects involved. void addGroup( Group* group ) { QF_STACK_TRY if ( !group ) { throw new System::ArgumentNullException(); } Group __pin *pThis = this; Group __pin *pGroup = group; pThis->unmanaged().addGroup( pGroup->unmanaged() ); QF_STACK_CATCH } On Thu, Jan 22, 2009 at 5:44 PM, Gehani, Neeraj <nee...@ci...>wrote: > QuickFIX Documentation: > http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX Support: http://www.quickfixengine.org/services.html > > Here is the log of exception this threw. > > This is the first time this problem has surfaced. App has been used for > almost half year. Any Ideas. > > 2009-01-22 13:30:06,515 [35] FATAL TradeManager - Attempted to read or > write protected memory. This is often an indication that other memory is > corrupt. at FIX.FieldMap.addGroup(FieldMap* , Int32 , FieldMap* , > Boolean ) > at QuickFix.Message.addGroup(Group group) > at FixUtil.createNewOrderList(FixRequestDetails frd) > at Communicator.SendNewOrderList(FixRequestDetails frd) > at TradeManager.Execute(Queue`1 queue) > at TradeManager.Manage(Object state) > > Code statements > > int listSeqNo = 0; > > QuickFix44.NewOrderList newOrderList = new > QuickFix44.NewOrderList(); > Hashtable listsCache = null; > > QuickFix.ListID listID = null; > > listsCache = > PortfolioManager.Instance.getListsCache(frd.PortfolioID); > > listID = new ListID("ABC"); > newOrderList.setField(listID); > > QuickFix.BidType bidType = new > QuickFix.BidType(QuickFix.BidType.DISCLOSED_STYLE); > newOrderList.setField(bidType); > > QuickFix44.NewOrderList.NoOrders sequenceGroup = null; > > foreach (Order order in orders.Values) > { > > sequenceGroup = new > QuickFix44.NewOrderList.NoOrders(); > SoupLogger.getLogger().InfoFormat("Processing > Frd={0} Order {1}", frd.getTag66(),order.ToString()); > sequenceGroup.setField(new > QuickFix.Account(order.ActMnc)); > sequenceGroup.setField(new > QuickFix.ClOrdID(order.OrderId)); > sequenceGroup.setField(new > QuickFix.ListSeqNo(++listSeqNo)); > sequenceGroup.setField(new > QuickFix.Symbol(order.Ticker)); > if (order.TickerSuff != null && > order.TickerSuff.Length != 0 ) sequenceGroup.setField(new > QuickFix.SymbolSfx(order.TickerSuff)); > > if (order.Side == OMConstants.BUY) > { > sequenceGroup.setField(new > QuickFix.Side(QuickFix.Side.BUY)); > } > else if (order.Side == OMConstants.SELL) > { > sequenceGroup.setField(new > QuickFix.Side(QuickFix.Side.SELL)); > } > else if (order.Side == OMConstants.SELLSHORT) > { > sequenceGroup.setField(new > QuickFix.Side(QuickFix.Side.SELL_SHORT)); > } > else if (order.Side == OMConstants.SELLSHORTEXEMPT) > { > sequenceGroup.setField(new > QuickFix.Side(QuickFix.Side.SELL_SHORT_EXEMPT)); > } > > string[] locateIdArr = order.LocateIds.Split(':'); > > sequenceGroup.setField(FixConstants.LOCATEBROKERNAME, locateIdArr[0]); > > sequenceGroup.setField(FixConstants.LOCATEBROKERID, locateIdArr[1]); > > > sequenceGroup.setField(new > QuickFix.OrderQty(order.Quantity)); > sequenceGroup.setField(FixConstants.SUBLISTID, > order.ListId); > sequenceGroup.setField(FixConstants.TRADERSOEID, > order.ClientName); > sequenceGroup.setField(new > IntField(FixConstants.SRCSYSTEMID,srcSystemId)); > sequenceGroup.setField(new > IntField(FixConstants.AGGUNIT, 999); > > sequenceGroup.setField(new > QuickFix.SenderCompID(senderCompId)); > sequenceGroup.setField(new > QuickFix.TargetCompID(targetCompId)); > sequenceGroup.setField(new > QuickFix.OrderID(order.OrderId)); > sequenceGroup.setField(new > QuickFix.TimeInForce(TimeInForce.DAY)); > sequenceGroup.setField(new > QuickFix.OrderCapacity(OrderCapacity.AGENCY)); > sequenceGroup.setField(new > QuickFix.UtcTimeStampField( FixConstants.ORDERFLOWENTRYTIME, > DateTime.UtcNow)); > > > > newOrderList.addGroup(sequenceGroup); > } > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers > |