1

I am having lib named Tplib.a. It is using map for storage for few data structure. Please see below:

typedef std::map<portNo_t, otnPortInfo_t> otnPortList_t;
otnPortList_t otnPortList;

    int mapOtnPortAdd( portNo_t portNo)
    {
      otnPortInfo_t otnPortInfo;

      memset(&otnPortInfo, 0, sizeof(otnPortInfo_t));
      otnPortInfo.portNo = portNo;
      ......
      ......
      otnPortInfo.sigDeg.state = 7;

      otnPortList[portNo] = otnPortInfo; // Problem line 

      return RET_Ok;
    }

After compilation of above lib(Tplib.a) when I am linking the above lib (Tplib.a) into a driver then it is crashing at run time at otnPortList[portNo] = otnPortInfo; // Problem line

But on another directory after linking Tplib.a working perfectly fine. no crash. Not sure what is the reason. Same lib is crashing at one place and not at other.

Any help how to proceed in debugging the issue. At every time I am seeing the following messages:

> map_initotn()
map_initotn [3834]: adding all port in one go
mapOtnPortAdd [3776]: portNo= 0

data translation miss
Exception current instruction address: 0x01dd8da8
Machine Status Register: 0x02029200
Data Exception Address Register: 0x5555aaba
Condition Register: 0x24000044
Exception Syndrome Register: 0x00000000
Task: 0x3423c68 "tShell"

187028 vxTaskEntry    +5c : shell (1)
 bf280 shell          +1dc: bf2a8 (1)
 bf568 shell          +4c4: execute (3423b30)
 bf754 execute        +f8 : yyparse ()
 df2bc yyparse        +ae0: dca04 (&yyval, 4f092d8, 4f092f8)
 dcc04 yystart        +b98: map_initotn() ()
1d82990 map_initotn()  +68 : mapOtnPortAdd(unsigned long) (0)
1d82664 mapOtnPortAdd(unsigned long)+bc : std::map<unsigned long, otnPortInfo_t, less<unsigned long>, __default_alloc_template<(bool)1, (int)0>>::operator [](const unsigned long  (&otnPortList, 34238e0)
1dd6998 std::map<unsigned long, otnPortInfo_t, less<unsigned long>, __default_alloc_template<(bool)1, (int)0>>::operator [](const unsigned long +90 : std::map<unsigned long, otnPortInfo_t, less<unsigned long>, __default_alloc_template<(bool)1, (int)0> ()
1dd7764 std::map<unsigned long, otnPortInfo_t, less<unsigned long>, __default_alloc_template<(bool)1, (int)0>+40 : rb_tree (3423728, &otnPortList, 3423738)
1dd8a90 rb_tree        +c8 : less<unsigned long>::operator ()(const unsigned long &, const unsigned long &) const (377f828, 3423738, 5555aaba)
tShell
 restarted.

I think its look like pure linking issue. Lib Tddrv.a is same no change in that but when the same code of piece of code is link in one directory it is working fine but in another directory it is crashing. I am using following tools compiler gcc.c3.4.5-p5.ppc and linker gld.c3.4.5-p5.ppc .

  • 2
    Don´t tag `C` if there is no C – deviantfan Jul 23 '14 at 15:09
  • @deviantfan: but that may be the issue, there is C (as per the `memset` call). – Matthieu M. Jul 23 '14 at 15:15
  • Have you tried iterating over the map and printing its content at the beginning of your method ? It may just be that the `map` is not initialized yet, for whatever reason. Also, we will need to know your toolchain (platform, compiler, linker) etc... – Matthieu M. Jul 23 '14 at 15:19
  • If `otnPortInfo_t` isn't a standard-layout type, then `memset(&otnPortInfo, 0, sizeof(otnPortInfo_t))` has undefined behavior. `otnPortInfo_t otnPortInfo = {};` will do the right thing whether it's a POD or not. – Casey Jul 23 '14 at 15:47
  • Sounds like a build remnant issue, have you tried to `find` all Tplib.a in the respective super-tree, deleted them, `make clean; make all` (or however your make/build tool needs to be invoked)? – Solkar Jul 23 '14 at 16:45
  • I think its look like pure linking issue. Lib Tddrv.a is same no change in that but when the same code of piece of code is link in one directory it is working fine but in another directory it is crashing. I am using following tools – user3869290 Jul 24 '14 at 07:40
  • I think its look like pure linking issue. Lib Tddrv.a is same no change in that but when the same code of piece of code is link in one directory it is working fine but in another directory it is crashing. I am using following tools compiler gcc.c3.4.5-p5.ppc and linker gld.c3.4.5-p5.ppc . – user3869290 Jul 24 '14 at 07:46
  • find and nm tools are displaying every symbol needed. – user3869290 Jul 24 '14 at 08:11

0 Answers0