Move a call to calloc to a place where it does not interfere with libc6's
calloc searching for the number of processes in use.
a
|
b
|
|
1192 | 1192 | int (*fn) (void *arg); |
1193 | 1193 | void *arg; |
1194 | 1194 | void *parentpcb; |
| 1195 | struct npcb *npcb; |
1195 | 1196 | }; |
1196 | 1197 | |
1197 | 1198 | /* create a new (reduced) pcb for a thread */ |
1198 | | static struct npcb *new_npcb(struct pcb *old) |
| 1199 | static struct npcb *new_npcb(struct pcb *old, struct npcb *npcb) |
1199 | 1200 | { |
| 1201 | /* |
1200 | 1202 | struct npcb *npcb; |
1201 | 1203 | npcb=calloc(1,sizeof(struct npcb)); |
| 1204 | npcb = tryit + alloced++ * sizeof(struct npcb); |
| 1205 | */ |
1202 | 1206 | npcb->flags=PCB_ALLOCATED; |
1203 | 1207 | /* inherit the treepoch path from the generating thread */ |
1204 | 1208 | npcb->tst=old->tst; |
… |
… |
|
1227 | 1231 | static int clonewrap(void *carg){ |
1228 | 1232 | int (*fn) (void *arg) = ((struct clonearg *)(carg))->fn; |
1229 | 1233 | void *arg=((struct clonearg *)(carg))->arg; |
| 1234 | struct npcb *npcb = ((struct clonearg *)(carg))->npcb; |
1230 | 1235 | /* create a new pcb for the new thread, and link the pcb with this new |
1231 | 1236 | * thread */ |
1232 | | set_pcb(new_npcb(((struct clonearg *)(carg))->parentpcb)); |
| 1237 | set_pcb(new_npcb(((struct clonearg *)(carg))->parentpcb, npcb)); |
1233 | 1238 | /* free the data structure used to keep the thread info */ |
1234 | 1239 | free(carg); |
1235 | 1240 | /* start the real thread */ |
… |
… |
|
1248 | 1253 | carg->fn=fn; |
1249 | 1254 | carg->arg=arg; |
1250 | 1255 | carg->parentpcb=get_pcb(); |
| 1256 | /* Calloc inside the new thread after the libc__clone call dumps core */ |
| 1257 | carg->npcb = calloc(1, sizeof(struct npcb)); |
1251 | 1258 | /* start a wrapper to the real main function of the thread */ |
1252 | 1259 | rv= libc__clone(clonewrap,child_stack,flags,carg,arg2,arg3,arg4); |
1253 | 1260 | return rv; |